【发布时间】:2017-02-02 21:21:26
【问题描述】:
我在尝试运行脚本时收到以下错误
org.testng.TestNGException:无法实例化类原因: java.lang.reflect.InvocationTargetException 原因: java.lang.IllegalStateException:驱动程序可执行文件的路径 必须由 webdriver.ie.driver 系统属性设置;
package EDRTermsPackge;
import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
public class ContactInformationTesting {
//For use of IE only; Please enable for IE Browser
WebDriver driver = new InternetExplorerDriver();
@BeforeMethod
public void beforeMethod() {
//Using or Launching Internet Explorer
String exePath = "\\Users\\jj85274\\Desktop\\IEDriverServer.exe";
//For use of IE only; Please enable for IE Browser
System.setProperty("webdriver.ie.driver", exePath);
}
@Test
public void OpenPage_Login() {
driver.get("http://cp-qa.harriscomputer.com/");
}
}
【问题讨论】:
-
@JJWhispers - 我相信您应该使用源代码更新您的问题,而不是将代码作为您自己问题的答案之一发布。我已经编辑了您的问题以包含您的源代码共享(我清理了注释掉的代码)