Java Selenium 2 Webdriver(无法通过xpath找到elemeny)

Java Selenium 2 Webdriver(无法通过xpath找到elemeny),java,internet-explorer,selenium-webdriver,Java,Internet Explorer,Selenium Webdriver,有人能告诉我我做错了什么吗?我曾尝试使用Firebug的xpath长格式,但我得到了相同的错误。使用xpath //span[@onclick=\"mainIframeSrc('l_sams_sched.p_group_schedule') 我能够找到元素并在Selenium IDE中单击“计划条目””。问题是当我尝试在IE中使用webdriver做同样的事情时 HTML代码片段: <div class="node"> <img alt="Schedule Entry" sr

有人能告诉我我做错了什么吗?我曾尝试使用Firebug的xpath长格式,但我得到了相同的错误。使用xpath

//span[@onclick=\"mainIframeSrc('l_sams_sched.p_group_schedule')
我能够找到元素并在Selenium IDE中单击“
计划条目”
”。问题是当我尝试在IE中使用webdriver做同样的事情时

HTML代码片段:

<div class="node">
<img alt="Schedule Entry" src="/csui/leaf.gif">
<span class="node-text" onmouseout="this.className='node-text'" onmouseover="this.className='node-text-over'" onclick="mainIframeSrc('l_sams_sched.p_group_schedule')">Schedule Entry</span>
</div>
driver.findElement(By.xpath("//span[@onclick=\"mainIframeSrc('l_sams_sched.p_group_schedule')\"]")).click();
错误:

<div class="node">
<img alt="Schedule Entry" src="/csui/leaf.gif">
<span class="node-text" onmouseout="this.className='node-text'" onmouseover="this.className='node-text-over'" onclick="mainIframeSrc('l_sams_sched.p_group_schedule')">Schedule Entry</span>
</div>
driver.findElement(By.xpath("//span[@onclick=\"mainIframeSrc('l_sams_sched.p_group_schedule')\"]")).click();
org.openqa.selenium.NoSuchElementException:找不到元素 通过xpath使用 “//span[@onclick=“mainIframeSrc('l_sams_sched.p_group_schedule')”” (7) 系统信息:os.name:'Windows XP',os.arch:'x86',os.version:'5.1',java.version:'1.6.0_19' 驱动程序信息:Driver.version:ie 位于org.openqa.selenium.ie.ErrorHandler.verifyErrorCode(ErrorHandler.java:36) 位于org.openqa.selenium.ie.Finder.handleErrorCode(Finder.java:219) 位于org.openqa.selenium.ie.Finder.findelementbypath(Finder.java:183) 位于org.openqa.selenium.By$6.findElement(By.java:205) 位于org.openqa.selenium.ie.Finder.findElement(Finder.java:207) 位于org.openqa.selenium.ie.InternetExplorerDriver.findelelement(InternetExplorerDriver.java:322) 在com.eviletester.seleniumtutorials.SAMSLogin.firstPageContainsQAANet(SAMSLogin.java:105)上 位于com.eviltester.seleniumtutorials.SAMSLogin.main(SAMSLogin.java:22) 测试失败

试试这个

WebElement element = driver.findElement(By.cssSelector("div.node>span.node-text"));
element.click();

在您试图在MSIE中访问的元素之前,页面中是否有id=“tags”的元素?如果是,您必须重命名它-请参阅下文

啊,还有一个可能的原因是安全设置-请参阅-查找“所需配置”