0
我已經在我的測試腳本下面的代碼在Selenium測試腳本中有多個同一頁面的對象可以嗎?
@Test
public void homePageNavigation()
{
LoginPage loginPage = PageFactory.initElements(driver, LoginPage.class);
//login function returns the HomePage object
HomePage homePage = loginPage.login(login, pass);
//navgateToProfilePage() function returns a ProfilePage object
ProfilePage profilePage = homePage.navgateToProfilePage();
//navigateBackToHomePage() function returns HomePage object and
//takes the user back to Home Page again
HomePage homePageReturn=profilePage.navigateBackToHomePage();
}
現在在上面的代碼,我有HomePage
即homePage
和homePageReturn
2個對象。在腳本中進一步使用它們可以嗎?
感謝 拉詹
爲什麼你不能navigateBackToHomePage();返回相同的對象,如「返回此;」 –
navigateBackToHomePage()函數在ProfilePage類中。 如果我寫回來這個,該函數將返回當前對象,即ProfilePage對象。 – Rajan