Below are the details related to my flow -
Problem -
Driver gets stuck, either Element 1 is not getting clicked or after adding sufficient wait Element 1 gets clicked but now driver gets stuck at this flow as you can observe from below code, once clickurl.click()
is called then after 10 seconds I should get a message that "Sleep Completed.. Now we return to calling class"
But instead I get exception.
Code -
clickurl = d1.findElement(By.xpath("XPath for Element 1"));
if ( clickurl != null ) {
System.out.print("****** Clicking on it Directly ");
clickurl.click();
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.print("****** Sleep Completed.. Now we return to calling class ");`
System Details -
Other Details -
driver.switchTo().defaultContent();
Error Details -
Dec 11, 2018 5:02:56 PM org.openqa.selenium.remote.ErrorCodes toStatus
INFO: HTTP Status: '500' -> incorrect JSON status mapping for 'timeout' (408 expected)
Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out waiting for page to load.
After trying multiple things and waits and using the settings from above answer, I used below code i.e. Moving the mouse to element and the performing click operation.
Actions actions = new Actions(d1);
actions.moveToElement(clickurl).click().build().perform();
js.executeScript("arguments[0].click();",clickurl);
I used below question to reach at this conclusion - Selenium click not always working