【发布时间】:2015-10-23 06:06:26
【问题描述】:
刚开始学习 selenium-webdriver 并且也在尝试....soo 这是我的dout吗?
下面创建了一个导航到谷歌主页的函数
包实用程序谷歌;导入 org.openqa.selenium.WebDriver; 导入 org.openqa.selenium.firefox.FirefoxDriver;
公共类主页{ WebDriver WD=null;
public static void main(WebDriver WD) {
// TODO Auto-generated method stub
WD = new FirefoxDriver();
WD.navigate().to("https://www.google.co.in");
WD.manage().window().maximize();
return;
}
及以下代码调用主页函数..
package GoogleMain;
import org.openqa.selenium.WebDriver;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import UtilityGoogle.HomePage;
public class Google_Tc1 {
private static WebDriver XP = null;@
Test
public void Open() {
HomePage HP = new HomePage();
String actual = XP.getTitle();
String expected = "Google";
AssertJUnit.assertEquals(expected, actual);
}
}
遇到以下错误....请帮我解决这个问题
FAILED: Open
java.lang.NullPointerException
at GoogleMain.Google_Tc1.Open(Google_Tc1.java:13)
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)
【问题讨论】:
标签: java selenium selenium-ide