亲爱的Selenium专家,
我从JPA 2.0程序中遇到了以下运行时错误,该程序似乎与Firefox Profile有关,原因如下:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:56)
at org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:79)
at model.DownloadCarDetail.getMercedezDetail(model.DownloadCarDetail:72)
at model.DownloadCarDetail.getMercedezDetail.main (model.DownloadCarDetail.getMercedezDetail.java:47)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 4 more
Java Result: 1
我已经将Firefox保留到版本15,以便Selenium Webdriver支持它,但怀疑问题与无法读取配置文件目录有关.
你的帮助非常适合.
非常感谢,
乔治
亲爱的Selenium Webdriver专家,
我想知道Selenium Webdriver中的字符串匹配方法是否与Java中的以下代码片段正常工作:
if (property.findElements(By.xpath("./dl[@class='cN-featDetails']/dd[matches(class,'propertytype type-house']")).size() > 0 ) { // line 229
Run Code Online (Sandbox Code Playgroud)
以下是第229行读取的xhtml网页:
<dl class="cN-featDetails">
<dt class="proptype">Property type</dt>
<dd id="ctl00_ctl00_Content_Content_SrchResLst_rptResult_ctl01_EliteListingTemplate_ddPropertyType" class="propertytype type-house" title="Property type: House">House</dd>
Run Code Online (Sandbox Code Playgroud)
但是,这导致以下错误:
Address: 28B/171 Gloucester Street, Sydney
Exception in thread "main" org.openqa.selenium.InvalidSelectorException: The given selector ./dl[@class='cN-featDetails']/dd[matches(class,'propertytype type-house'] is either invalid or does not result in a WebElement. The following error occurred:
[InvalidSelectorError] Unable to locate an element with the xpath expression ./dl[@class='cN-featDetails']/dd[matches(class,'propertytype type-house'] because of the following error:
[Exception... "The expression is not a …Run Code Online (Sandbox Code Playgroud) 我想使用getPageSource()方法将当前页面源保存在指定文件夹中的不同名称下.例如,将当前页面源保存为C:/ Holiday文件夹下的Hawai.htm.
包括Java doc在内的大多数参考资料只涉及到getPageSource(),但没有具体说明在这种情况下不需要的东西.
我在Windows平台上使用Selenium Webdriver 2 Java(JDK 7).