Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 需要有关selenium脚本的特定testng错误的帮助吗_Java_Selenium - Fatal编程技术网

Java 需要有关selenium脚本的特定testng错误的帮助吗

Java 需要有关selenium脚本的特定testng错误的帮助吗,java,selenium,Java,Selenium,我在执行下面的命令 public WebDriver getDriver() { System.setProperty("webdriver.chrome.driver", "/Applications/chromedriver"); WebDriver driver = new ChromeDriver(); return driver; } @Test public void firstTry() { getDriver().get("www.google

我在执行下面的命令

public WebDriver getDriver() {
    System.setProperty("webdriver.chrome.driver", "/Applications/chromedriver");
    WebDriver driver = new ChromeDriver();
    return driver;
}


@Test
public void firstTry() {
    getDriver().get("www.google.com");
}
将以下内容作为错误获取

Sep 03, 2018 3:39:20 PM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`

java.lang.AbstractMethodError: org.openqa.selenium.remote.DesiredCapabilities.is(Ljava/lang/String;)Z

已导入所有必需的罐子。在macOS上运行它,有什么原因让我得到这个吗?任何答案都会大有帮助。提前谢谢

我不明白你到底有什么问题

但如果您使用Windows,则需要这样更改。需要在chromedriver中添加.exe,并在获取URL时添加https://

public WebDriver getDriver() {
    System.setProperty("webdriver.chrome.driver", "/Applications/chromedriver/chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    return driver;
}


@Test
public void firstTry() {
    getDriver().get("https://www.google.com");
}

首先使用所有最新的JAR和chromedriver.exe文件

使用完整的URL,包括http


看起来有jar冲突,请尝试只使用一个jar,即Selenium独立服务器jar。如果问题得到解决,请查看您的jar。对于特定于java的JAR,您可以从此处下载

浏览器未打开,未发生任何事情,脚本显示错误。我不在windows上。好的,我会检查,您正在使用Mac。请告诉我您使用的selenium JAR,以及您是否正在使用所需的功能未使用所需的功能。我使用的jar是selenium-java-3.14.0、java-json.jar、selenium-java.jar、java-client-6.1.0.jar、selenium-chrome-driver-2.26.0.jar在端口23838上启动ChromeDriver 2.14.313457(3D645C400EDF2E2C500566C9AA09063E707C9CF),只允许本地连接。[警告]kq_init:检测到断开的kqueue;未使用:未定义错误:0 Sep 042018 1:59:12 PM org.openqa.selenium.remote.ProtocolHandshake createSession信息:检测到的方言:oss在我将JAR更改为正确的JAR时将上述注释作为错误获取。新的chrome会话正在打开,但未导航到所需的URL。请尝试使用完整的URL,如http://www。google.com(无空格)