Selenium 2.0 WebDriver IE8 findelement by xpath cannot be evaluated

When I run the following code in Firefox, it works correctly, but IE8 says that xpath cannot be evaluated or will not lead to the creation of a WebElement.

webDriver.findElement(By.xpath("//input[@id='submitForm']")).sendKeys("\n");

OR

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

I tried the alternative xpath "// div [@id = 'parameters'] / table / tbody / tr [4] / th / input", but it gives the same result.

It seems to me that this is an IE driver problem, please let me know if there is any work.

+5
source share
2 answers

Could you try as shown below?

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

For IE, native XPath support is not supported, for this WebDriver uses a third-party javascript-xpath library , it may be its error.

+4

IE 8 3 , -

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

   WebDriver webDriver= new InternetExplorerDriver(ieCapabilities);

Xpath Id:

 webDriver.findElement(By.id("submitForm")).click();
+1

All Articles