微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java – 使用Selelnium时,我收到了一个错误

我下载了独立服务器文件,驱动程序文件,然后复制到库中.我已经将selenium文件中的“lib”文件夹移动到了Library位置.这是代码

    package google.search;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class GoogleSearch {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // Create a new WebDriver object (Firefox browser)
WebDriver bot = new HtmlUnitDriver();

// Navigating to google.com
bot.get("http://www.google.com");

// Find the text input element by its name
WebElement inputField = bot.findElement(By.name("q"));

// Send some keys into the textfield
inputField.sendKeys("Selenium is easy");

// Submit your text (to start a google search)
inputField.submit();

// Saving the page source code into a string
String pageSource = bot.getPageSource();

//Closing the Firefox browser and "shutdown" the WebDriver object
bot.quit();
    }

}

即使现在我没有得到红色错误指示器,我仍然得到我之前从未遇到的这个奇怪的错误.谁能告诉我这意味着什么?

Feb 21, 2015 1:02:49 AM com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement addBehavior
WARNING: Unimplemented behavior: #default#userdata

解决方法:

您可以为HtmlUnitDriver添加BrowserVersion类对象以删除此错误

WebDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_24);

对象名称可以用不同的相应名称替换.这也与创建浏览器特定的驱动程序不同,例如FirefoxDriver()

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐