Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Internet explorer 无法使用internet explorer中的Xpath在selenium中定位元素_Internet Explorer_Selenium - Fatal编程技术网

Internet explorer 无法使用internet explorer中的Xpath在selenium中定位元素

Internet explorer 无法使用internet explorer中的Xpath在selenium中定位元素,internet-explorer,selenium,Internet Explorer,Selenium,我在chrome浏览器中尝试了下面的代码,代码运行良好,但在InternetExplorer中,同样的代码不起作用,表示没有这样的元素错误。 不确定internet explorer在处理它们时是否有任何问题。我使用的是windows 10操作系统和internet explorer。 在Internet explorer中,当我想单击“新建业务”链接时,我可以在登录页后使用selenium登录,但它不起作用, 但同样的代码在chrome中也能正常工作。这有什么原因吗? 我使用的是seleniu

我在chrome浏览器中尝试了下面的代码,代码运行良好,但在InternetExplorer中,同样的代码不起作用,表示没有这样的元素错误。 不确定internet explorer在处理它们时是否有任何问题。我使用的是windows 10操作系统和internet explorer。 在Internet explorer中,当我想单击“新建业务”链接时,我可以在登录页后使用selenium登录,但它不起作用, 但同样的代码在chrome中也能正常工作。这有什么原因吗? 我使用的是selenium 2.52 java和相同的IEdriver

driver.findElement(By.xpath("//a[contains(@href, 'menuopt=PolicyType&TransTyp=NB')]")).click();
driver.findElement(By.xpath("//*[text()='New Business - Rate']/ancestor::a")).click();
driver.findelement(By.cssselector(a[href*='TransTyp=NBS'])).click ();

你试过这个吗

driver.findElement(By.xpath("//a[contains(text(), 'New Business - Rate')]")).click()

你试过这个吗

driver.findElement(By.xpath("//a[contains(text(), 'New Business - Rate')]")).click()

这并不能回答这个问题。若要评论或要求作者澄清,请在其帖子下方留下评论。-@你怎么知道它不提供答案?他识别元素的方式是不可靠的。我提供了一种更稳定的方法来识别可能在IE中工作的。。谢谢你的评论。那么请不要把它当作问题来写。@Tree55Topz很抱歉,它也没有解决问题,遇到了同样的错误,无法用Xpath找到元素。。我使用的是IE 11,正如我之前所说的,同样的代码在Chrometh中工作,但这并不能回答这个问题。若要评论或要求作者澄清,请在其帖子下方留下评论。-@你怎么知道它不提供答案?他识别元素的方式是不可靠的。我提供了一种更稳定的方法来识别可能在IE中工作的。。谢谢你的评论。那么请不要把它当作问题来写。@Tree55Topz很抱歉,它也没有解决问题,遇到了同样的错误,无法用Xpath找到元素。。我使用的是IE 11,正如我之前所说的,同样的代码在chrome中也能工作