我在autoamted測試新手使用webdriver.Would有人請檢查爲什麼我收到顯示java.lang.NullPointerException的webdriver
java.lang.NullPointerException
at SuccessfullHoverTestCib.testSuccessfullHoverTestCib
(SuccessfullHoverTestCib.java:29)
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).....
我運行下面的代碼:
public class SuccessfullHoverTestCib {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
File pathToFirefoxBinary = new File("C:\\Documents and Settings\\chakarova\\Local Settings\\Application Data\\Mozilla Firefox\\firefox.exe");
FirefoxBinary firefoxbin = new FirefoxBinary(pathToFirefoxBinary);
WebDriver driver = new FirefoxDriver(firefoxbin,null);
baseUrl = "http://cibnew.sofia.ifao.net:7001/cib_web/web";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testSuccessfullHoverTestCib() throws Exception {
driver.get(baseUrl);
driver.findElement(By.id("inputButton")).click();
driver.findElement(By.linkText("Hotels")).click();
driver.findElement(By.id("pageLink_57")).click();
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
當我指向錯誤跟蹤,它鏈接到測試method->driver.get(baseUrl);
我認爲問題與firefox.exe
的路徑的定義相關,但我不知道如何解決它。任何幫助將不勝感激。
哪一行是SuccessfullHoverTestCib.java:29? –