只需投入Java!試圖實現BDD風格的框架...... 我遇到這個問題跨類|創建webdriver實例硒Java
我Driver.java看起來是這樣的:
public class Driver {
public static WebDriver Instance;
@Before
public void InitializeTest() {
System.setProperty("webdriver.chrome.driver", "C://chromedriver.exe");
Instance = new ChromeDriver();
}
@After
public void TearDownTest(Scenario scenario) {
//close the browser
if (scenario.isFailed()) { //take Screenshot
System.out.println(scenario.getName());
}
Instance.close();
}
}
我的步驟定義文件:
public class MyStepdefs {
public static String Url = "https://ebay.com/staging/";
LoginPage loginPage = new LoginPage();
@Given("^I login to Ebay as \"([^\"]*)\"$")
public void iLoginToEbayAs(String username) throws Throwable {
Driver.Instance.navigate().to(Url);
loginPage.setUserName().sendKeys(username);
loginPage.setPassword().sendKeys("seeeev");
}
收到此錯誤:
java.lang.NullPointerException at Steps.MyStepdefs.iLoginToEbayAs(MyStepdefs.java:4)
MyStepdefs.java:4 == Driver.Instance.navigate().to(Url);
幫我通過這個!
你從未提及過你面臨的問題? –
對不起,芽!剛剛更新... – cashanzlo
您正在使用哪個庫或測試框架? –