【发布时间】:2017-02-28 01:56:36
【问题描述】:
线程“main”中的异常 java.lang.IllegalStateException:驱动程序可执行文件的路径必须由 webdriver.gecko.driver 系统属性设置;有关详细信息,请参阅https://github.com/mozilla/geckodriver。最新版本可以从https://github.com/mozilla/geckodriver/releases下载
这是我的代码。
package newpackage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class MyClass {
public static void main(String[] args) {
//declaration and instatiation of objects/variables
WebDriver driver = new FirefoxDriver();
String baseUrl = "http://newtours.demoaut.com";
String expectedTitle = "Welcome: Mercury Tours";
String actualTitle ="";
//launch firefox and direct it to the URL
driver.get(baseUrl);
//get the actual value of the title
actualTitle = driver.getTitle();
if (actualTitle.contentEquals(expectedTitle)){
System.out.println("Test Passed");
}else {
System.out.println("Test failed");
}
//close firefox
driver.close();
//exit the program
System.exit(0);
}
}
【问题讨论】:
-
当你按照它的指示...?
-
在问题中添加适当的标签很重要。大多数寻找可以回答的问题的人都会搜索他们熟悉的语言,因此您至少应该将其作为标签包含在内。您还应该阅读 Stack Overflow 的 markdown 格式,以使您的问题更具可读性。这次我为你编辑了你的问题;请学会自己做。