org openqa selenium ElementClickInterceptedException

0 votes
getting thei error:

Exception in thread "main" org.openqa.selenium.ElementClickInterceptedException: Element <button id="button1"> is not clickable at point (408,594) because another element <div id="cookie-law-info-bar"> obscures it

code is:

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

String parentwindow = driver.getWindowHandle();

System.out.println("parent windowhandle is  "+ parentwindow);

WebElement clickbutton = driver.findElement(By.id("button1"));

for(int count = 0;count <2;count++)

{

clickbutton.click();

System.out.println("count is " + count );

}

Then I used the Actions class and moveToElement method . Even that method gave this error "MoveTargetOutOfBoundsException"

Error:

Exception in thread "main" org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (408, 611) is out of bounds of viewport width (1280) and height (607)

Code:

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

String parentwindow = driver.getWindowHandle();

System.out.println("parent windowhandle is  "+ parentwindow);

WebElement clickbutton = driver.findElement(By.id("button1"));

for(int count = 0;count <2;count++)

{

Actions action = new Actions(driver);

action.moveToElement(clickbutton).click().perform();

clickbutton.click();

System.out.println("count is " + count );

}

Then I used the Point class and movetoElement and moveByOffset method.that also gave the error "MoveTargetOutOfBoundsException" error

Error:

Exception in thread "main" org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (408, 611) is out of bounds of viewport width (1280) and height (607)

Code:

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

String parentwindow = driver.getWindowHandle();

System.out.println("parent windowhandle is  "+ parentwindow);

WebElement clickbutton = driver.findElement(By.id("button1"));

for(int count = 0;count <2;count++)

{

Actions action = new Actions(driver);

Point p = clickbutton.getLocation();

action.moveToElement(clickbutton).moveByOffset(p.y, p.y).click().perform();

clickbutton.click();

System.out.println("count is " + count );

}

Finally the code that worked for me is using the Dimensions class and setting the dimension of the parent window.Below code worked:

public static void main(String[] args) {

System.setProperty("webdriver.gecko.driver", "C:\\Users\\sudv\\eclipse-workspace\\Selenium\\Drivers\\geckodriver.exe");

WebDriver driver= new FirefoxDriver();

driver.get("http://toolsqa.com/automation-practice-switch-windows/");

Dimension origsize = driver.manage().window().getSize();

System.out.println("actual main window size is  " + origsize);

Dimension dim = new Dimension(500,1000);

      //Resize current window to the set dimension

      driver.manage().window().setSize(dim);

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

String parentwindow = driver.getWindowHandle();

System.out.println("parent windowhandle is  "+ parentwindow);

WebElement clickbutton = driver.findElement(By.id("button1"));

for(int count = 0;count <2;count++)

{

//Actions action = new Actions(driver);

//action.moveToElement(clickbutton).click().perform();

//Point p = clickbutton.getLocation();

//action.moveToElement(clickbutton).moveByOffset(p.y, p.y).click().perform();

clickbutton.click();

System.out.println("count is " + count );

}

Set<String> allwindows = driver.getWindowHandles();

Iterator<String> i1 = allwindows.iterator();

while(i1.hasNext())

{

String childwindow = i1.next();

if(!parentwindow.equalsIgnoreCase(childwindow))

{

    System.out.println("child window is " + childwindow);

driver.switchTo().window(childwindow);

driver.get("http://www.facebook.com");

}

}

System.out.println("switching to parent window  "+parentwindow);

driver.switchTo().window(parentwindow);

driver.manage().window().maximize();

}

}
Nov 11, 2019 in Selenium by Sridevi
• 120 points
7,550 views
Hey@sridevi, Does using the Dimensions class and setting the dimension of the parent window solve the issue that you were facing earlier? If so, could you please put that up as an answer. It might be helpful in the long run!

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Selenium

0 votes
0 answers

org.openqa.selenium.ElementClickInterceptedException Selenium WebDriver Java

Hello, My execution does clicks on webelement as ...READ MORE

Jul 21, 2020 in Selenium by sainiranjan
• 120 points
12,917 views
0 votes
1 answer
0 votes
2 answers

Selenium Webdriver Error: org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value'

Facing Error Exception in thread "main" org.openqa.selenium .WebDriverException: unknown ...READ MORE

answered Mar 5, 2020 in Selenium by anonymous
10,115 views
+1 vote
1 answer

Selenium Eror: org.openqa.selenium.UnhandledAlertException: unexpected alert open

Even I had a similar problem. This ...READ MORE

answered May 29, 2018 in Selenium by sniffy_god
• 780 points
15,159 views
0 votes
4 answers
0 votes
1 answer

Error: org.openqa.selenium.ElementNotInteractableException

Try to use javascriptExecutor to click the ...READ MORE

answered Jul 30, 2018 in Selenium by Samarpit
• 5,910 points
7,755 views
0 votes
0 answers

org.openqa.selenium.WebDriverException: Unable to convert: {actions=[org.openqa.selenium.interactions.Sequence@737edcfa, org.openqa.selenium.interactions.Sequence@3ecedf21]}

I am getting error  org.openqa.selenium.WebDriverException: Unable to convert: ...READ MORE

Mar 23, 2020 in Selenium by Manish
• 140 points
2,437 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP