Selenium webdriver と testng で Page オブジェクト パターンを使用しています。あるページ オブジェクト クラスのインスタンスに、複数の<test>
.
例えば
<test name="Login scenario">
<classes>
<class name="sanitytests.LoginTests">
<methods>
<include name="validLogin"/>
</methods>
</class>
</classes>
</test>
<test name="scenario2" preserve-order="true" parallel="false">
<classes>
<class name="sanitytests.HomePageTests">
<methods>
<include name="clickOnMyAccountFromHome"/>
</methods>
</class>
</classes>
</test>
LoginTests クラスで、homePage クラスのインスタンスを使用しています
@Test()
public void validLogin(ITestContext context) throws Exception {
loginPage.loginDetails(username,password);
homePage = loginPage.loginAsValidUser();
context.setAttribute("homePage",homePage);
}
私の HomePageTests クラス
@Test()
public void clickOnMyAccountFromHome(ITestContext context) throws Exception {
homePage = (HomePage) context.getAttribute("homePage");
myAccountPage = homePage.navigateToMyAccountPage();
context.setAttribute("myAccountPage", myAccountPage);
}
ItestContext
テスト間ではなくメソッド間でパラメーターを共有するために使用されるため、null ポインター例外が発生しています。代替手段はありますか?