2011-09-06 96 views
3

有人能告诉我我做错了什么吗?我试过使用Firebug的xpath的长格式,并且我得到了同样的错误。使用XPathSelenium 2 Webdriver(无法通过xpath找到elemeny)

//span[@onclick=\"mainIframeSrc('l_sams_sched.p_group_schedule') 

我能找到的元素和硒IDE点击“Schedule Entry”。问题是,当我尝试在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> 

的webdriver代码:

driver.findElement(By.xpath("//span[@onclick=\"mainIframeSrc('l_sams_sched.p_group_schedule')\"]")).click(); 

错误:

org.openqa.selenium.NoSuchElementException: Unable to find element by xpath using "//span[@onclick="mainIframeSrc('l_sams_sched.p_group_schedule')"]" (7) System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_19' Driver info: driver.version: ie at org.openqa.selenium.ie.ErrorHandler.verifyErrorCode(ErrorHandler.java:36) at org.openqa.selenium.ie.Finder.handleErrorCode(Finder.java:219) at org.openqa.selenium.ie.Finder.findElementByXPath(Finder.java:183) at org.openqa.selenium.By$6.findElement(By.java:205) at org.openqa.selenium.ie.Finder.findElement(Finder.java:207) at org.openqa.selenium.ie.InternetExplorerDriver.findElement(InternetExplorerDriver.java:322) at com.eviltester.seleniumtutorials.SAMSLogin.firstPageContainsQAANet(SAMSLogin.java:105) at com.eviltester.seleniumtutorials.SAMSLogin.main(SAMSLogin.java:22) Test failed.

回答

相关问题