2011-09-06 117 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.

回答

相關問題