过去几个小时我一直在努力解决这个问题。我正在尝试安装Selenium Web驱动程序,并且遇到了一堆错误,导致我无法运行测试页面。我很确定我最近的问题是这段代码:
public static void main(String[] args) throws InterruptedException{
System.setProperty("webdriver.gecko.driver","C:/Users/theone/Downloads/geckodriver 2.exe");
非常感谢第二步的任何反馈!
package automationFramework;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FirstTestCase {
public static void main(String[] args) throws InterruptedException{
System.setProperty("webdriver.gecko.driver","C:/Users/theone/Downloads/geckodriver 2.exe");
// Create a new instance of the Firefox driver
WebDriver driver = new FirefoxDriver();
//Launch the Online Store Website
driver.get("http://www.store.demoqa.com");
// Print a Log In message to the screen
System.out.println("Successfully opened the website www.Store.Demoqa.com");
//Wait for 5 Sec
Thread.sleep(5);
// Close the driver
driver.quit();
}
}
答案 0 :(得分:3)
您可以使用webdriver.gecko.driver属性或使用环境属性使用GeckoDriver设置Selenium。如果您使用最新版本的Firefox,GeckoDriver和Selenium 3.0
,那就太好了查看这篇文章,它使用这两种方式提供设置 - http://automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/
答案 1 :(得分:3)
C:/Users/theone/Downloads/geckodriver 2.exe
路径中有空格,如果您重命名文件 geckodriver2.exe ,它可能会有效。