程序不执行精细硒

时间:2017-11-06 20:27:29

标签: selenium webdriver

我下载了Selenium 2.53版本,现在我有Selenium 3.2版本,两次打开相同的空白页面,没有URL。请输入以下错误消息。

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class AadminLogin {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.setProperty("WebDriver.gecko.driver","C:/geckoDriver.exe");
        WebDriver driver= new FirefoxDriver();
        driver.get("http://www.gmail.com");
        driver.findElement(By.id("Email")).sendKeys("Kawal");`
    }
}
  

构建信息:版本:'未知',修订版:'8c03df6',时间:'2017-03-02 09:30:17 -0800'   系统信息:主机:'DESKTOP-BTAFHIV',ip:'192.168.153.1',os.name:'Windows 10',os.arch:'amd64',os.version:'10 .0',java.version:'1.8 .0_144'   驱动程序信息:driver.version:FirefoxDriver       在org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)       在org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)       在org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)       在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)       在org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)       在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:131)       在org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:293)       在org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:272)       在org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:267)       在org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:263)       在org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:122)       在abcd.AadminLogin.main(AadminLogin.java:12)

2 个答案:

答案 0 :(得分:0)

您需要更改:

System.setProperty("WebDriver.gecko.driver","C:/geckoDriver.exe");

致:

System.setProperty("webdriver.gecko.driver","C:/geckodriver.exe");
  

在Selenium 3.x中,键值对表示为 webdriver.gecko.driver C:/geckoDriver.exe

答案 1 :(得分:0)

尝试更新代码:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class AadminLogin {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.setProperty("webdriver.gecko.driver","C:/geckodriver.exe"); //Here changes are made
        WebDriver driver= new FirefoxDriver();
        driver.get("http://www.gmail.com");
        driver.findElement(By.id("Email")).sendKeys("Kawal");`
    }
}

其他一切都很好。这只是setProperty()中的一些套管问题。对于2.53,不需要geckodriver