2012-12-21 25 views
1

硒webDriver只是没有通过调用driver.findElement(By.className("item")); 找到元素时什么也不做,驱动程序甚至不会抛出ElementNotfoundException,我有时会期待。它只是挂起。 这里有一个例子:Selenium 2:“driver.findElement(By ....);

ProfilesIni allProfiles = new ProfilesIni(); 
FirefoxProfile profile = allProfiles.getProfile("default"); 
driver = new FirefoxDriver(profile); 
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); 
driver.get(APP_ADDRESS); 

WebElement sBoxPopup = driver.findElement(By 
       .className("item")); 
... 

司机挂在driver.findElement(...)。即使我删除隐含的等待,它也会挂起。 我正在寻找4天以来的错误。我希望有人可以提供一个提示。 我使用Firefox 17.0.1和selenium-java/-server 2.28。我也将硒版本降级到2.25,没有任何反应。

回答

0

你可以尝试降低你的firefox版本到16,并尝试。

0

尝试用driver.findelement(By.xpath( “// * [@类= '日期']”

+0

我的xpath中没有空间string! – slowessam

+0

try it :: driver.findelement(By.xpath(“// * [@ class ='item']”) –

0

) 天色如果类名包含空间 “DA TE” 的className将无法工作。我想错误在xpath本身,因为在你的网页中可能会有更多的次数“class = item”。尝试通过在你的网页中找到一些唯一的字符串来改变xpath。