【发布时间】:2017-10-10 04:14:31
【问题描述】:
您好,我收到以下错误,谁能帮我调试下面的代码,
打包测试ngpackg;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class ARXNewTest {
ChromeDriver driver;
@BeforeMethod
public void set() {
//ProfilesIni profile = new ProfilesIni();
//FirefoxProfile testprofile = profile.getProfile("default");
// testprofile.setAcceptUntrustedCertificates(true);
//testprofile.setAssumeUntrustedCertificateIssuer(true);
System.setProperty("webdriver.chrome.driver", "C:\\Selenium Web Driver 3.0.1\\geckodriver-v0.12.0-win32\\geckodriver.exe");
WebDriver driver = new ChromeDriver();
String baseURL = "<URL>";
driver.get(baseURL);
driver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS);
}
@Test
public void OpenBrowser() {
driver.findElement(By.linkText("Log In")).click();
driver.switchTo().frame(0);
driver.findElement(By.id("tx_username")).sendKeys("my email id");
}
}
错误
失败:打开浏览器
java.lang.NullPointerException
at testngpackg.ARXNewTest.OpenBrowser(ARXNewTest.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:646)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:811)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1129)
执行上述代码时出现空点错误
【问题讨论】:
标签: java selenium selenium-webdriver testng