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 10 in Selenium by Sridevi
• 120 points
132 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
1 answer
+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
4,561 views
0 votes
1 answer
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,150 points
2,180 views
0 votes
1 answer

How can I download the *.jar file from http:// seleniumhq.org using selenium WebDriver?

For Selenium Standalone Server use this: profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/java-archive"); and ...READ MORE

answered Apr 9, 2018 in Selenium by Martin
• 4,230 points
687 views
0 votes
1 answer

What is the difference between thoughtworks.selenium and openqa.selenium selenium?

thoughtworks.selenium is the original Selenium (aka Selenium 1, ...READ MORE

answered Apr 13, 2018 in Selenium by king_kenny
• 3,650 points
311 views