Search code examples
javaseleniuminternet-explorerselenium-iedriveriedriverserver

HTTP Status: '500' -> incorrect JSON status mapping for 'timeout' (408 expected) while clicking element with IEDriverServer Selenium and Java


Below are the details related to my flow -

  • Page - 1 - Login to Web page
  • After login, a URL Appears (Lets call it Element 1)
  • After clicking Element 1, web page loads again and there I need to click on a different element, (Lets call it Element 2).

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 -

  • InternetExplorerDriver server (64-bit) 3.14.0.0
  • Os name: 'Windows 10'
  • Java version: '1.8.0_191'

Other Details -

  • Please note that after clicking on Element 1, I use 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.

Solution

  • 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