简体   繁体   English

Selenium JAVA xPath Firefox与Internet Explorer

[英]Selenium JAVA xPath Firefox vs Internet Explorer

I am working with the RemoteWebDriver, Firefox the Selenium IDE and JAVA. 我正在使用RemoteWebDriver,Firefox Selenium IDE和JAVA。

From the start I run the IDE to check and debug the web page. 从一开始,我就运行IDE来检查和调试网页。 I got an xpath the value like this using the IDE: 我使用IDE获得了一个xpath的值,如下所示:

driver.get(baseUrl + "/url?value=something");
driver.findElement(By.xpath("(//li[@onclick='menu.open(this)'])[4]")).click();

...using JAVA with RemoteWebDriver and findElementByPath(...) or findElement(By.xpath(...)) I got the exception: ...将JAVA与RemoteWebDriver和findElementByPath(...)或findElement(By.xpath(...))一起使用时,出现了以下异常:

EXCEPTION: Unable to find element with xpath == (//li[@onclick='menu.open(this)'])[4] 例外:无法使用xpath ==找到元素(//li[@onclick='menu.open(this)'])[4]

I played with the value and try those by IDE and by JAVA: 我玩过这个值,并尝试通过IDE和JAVA进行尝试:

    (//li[@onclick='menu.open(this)'])[4]
    and
    //li[@onclick='menu.open(this)'][4]

With IDE it works with JAVA not... 使用IDE不能与JAVA一起使用...

Update and correction! 更新和更正!

I modified the test program to use Firefox instead IE (Version 11) and it works. 我将测试程序修改为使用Firefox而不是IE(版本11),并且可以正常工作。 What is the different handling in using xpath with IE and Firefox? 在IE和Firefox中使用xpath有什么不同的处理方式? Or more generally which browser works with xpath in which way and the same value? 或更笼统地说,哪种浏览器以相同的方式和xpath一起使用?

Update 更新资料

The page is running in IE Version 7 mode. 该页面在IE版本7模式下运行。 May this causes the trouble?!? 这会引起麻烦吗?!?

请检查链接是否可以帮助您IE X-Path

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Java将用于Firefox的Selenium IDE转换为Chrome和Internet Explorer - Convert selenium IDE for firefox to chrome and internet explorer using Java 使用Java的Internet Explorer上运行Selenium 2.12失败 - Running Selenium 2.12 fails on Internet Explorer with Java Internet Explorer未从Java的Selenium 2.48打开 - Internet Explorer is not opening from selenium 2.48 for Java 单击Selenium with Java for Internet Explorer中的单选按钮 - Clicking a radio button in Selenium with Java for Internet Explorer selenium 未检测到 firefox 中的链接,但相同的测试在 Internet Explorer 中运行良好 - selenium not detecting a link in firefox but same test runs fine in internet explorer Selenium:Internet Explorer中的NoSuchElementException - Selenium: NoSuchElementException in Internet Explorer Internet Explorer中的Selenium Webdriver - Selenium Webdriver in Internet explorer Selenium Internet Explorer 问题:org.openqa.selenium.NoSuchElementException:无法使用 xpath 找到元素 - Selenium Issue with Internet Explorer : org.openqa.selenium.NoSuchElementException : Unable to find element with xpath Selenium-Internet Explorer-Java-如何禁用图像加载? - Selenium - Internet explorer - Java - How to disable images loading? 是否有明确的 Selenium 解决方案来使用 Java 在 Internet Explorer 中弹出模态弹出对话框? - Is there a definite Selenium solution to modal pop up dialogs in Internet Explorer with Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM