Selenium 2.0 WebDriver IE8 findelement by xpath cannot be evaluated

后端 未结 2 1255
渐次进展
渐次进展 2021-01-06 03:13

When I run the following code in Firefox it runs correctly, but in IE8 it says xpath cannot be evaluated or does not result in a WebElement.

webDriver.findEl         


        
相关标签:
2条回答
  • 2021-01-06 03:42

    IE 8 need this top 3 line compulsory in selenium web driver

       DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer(); 
       ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
    
       WebDriver webDriver= new InternetExplorerDriver(ieCapabilities);
    

    Please change Xpath by Id:

     webDriver.findElement(By.id("submitForm")).click();
    
    0 讨论(0)
  • 2021-01-06 03:48

    Could you try as below?

    webDriver.findElement(By.xpath("//input[string(@id)='submitForm']")).click()
    

    For IE doesn't have native XPath support, WebDriver use a third-party library called javascript-xpath for this, this may be a bug of it.

    0 讨论(0)
提交回复
热议问题