I tried the test with the "noReset" capability set to "true" (user is already logged in) and with only these statements in the Test method at first:
assertTrue(app.dashboardPage().isDashboardOpened());
Thread.sleep(5000);
app.dashboardPage().clickProfileIcon();
assertTrue(app.profilePage().isProfileOpened());
app.profilePage().openSettings();
assertTrue(app.settingsPage().isSettingsOpened());
app.settingsPage().clickNotificationSettings();
assertTrue(app.notificationPage().isNotificationOpened());
assertTrue(app.notificationPage().isToggleOff());
and it passes.
However, my test fails when I try to add these statements in the test (user has to login first)
doLogin();
if (app.onboardingPage().isNotificationMessageDisplayed() == true) {
app.onboardingPage().clickNo();
}
if (app.onboardingPage().isUpdateRealAgeDisplayed() == true) {
app.onboardingPage().clickNo();
}
if (app.onboardingPage().isLaterVisible() == true) {
app.onboardingPage().clickLater();
assertTrue(app.onboardingPage().isContinueLaterVisible());
app.onboardingPage().clickDialogYes();
}
I don't get how it could have a TimeOutException when I can see profile_icon on the screen. I already tried changing the wait duration but it will still produce the TimeOutException.
Here are my classes:
Test Class
@BeforeMethod
public void connect() throws MalformedURLException {
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "7.0");
caps.setCapability("deviceName", "Sony Xperia XA Ultra");
caps.setCapability("appPackage", "---");
caps.setCapability("appActivity", ".ui.MainActivity");
caps.setCapability("noReset", "false");
driver = new AndroidDriver<MobileElement>(new URL("http://ift.tt/1eWSHgW"), caps);
app = new App(driver);
}
public void doLogin() {
app.landingPage().allowPermission();
app.landingPage().goToLoginPage();
credentials = new UserCredentials("lmpgdn@gmail.com", "11111111");
app.loginPage().enterEmailAddress(credentials.getEmailAddress());
app.loginPage().enterPassword(credentials.getPassWord());
app.loginPage().clickLogin();
assertTrue(app.onboardingPage().isOnboardingOpened());
}
@Test (priority = 2)
public void dontAllowNotifications() throws InterruptedException {
doLogin();
if (app.onboardingPage().isNotificationMessageDisplayed() == true) {
app.onboardingPage().clickNo();
}
if (app.onboardingPage().isUpdateRealAgeDisplayed() == true) {
app.onboardingPage().clickNo();
}
if (app.onboardingPage().isLaterVisible() == true) {
app.onboardingPage().clickLater();
assertTrue(app.onboardingPage().isContinueLaterVisible());
app.onboardingPage().clickDialogYes();
}
assertTrue(app.dashboardPage().isDashboardOpened());
Thread.sleep(5000);
app.dashboardPage().clickProfileIcon();
assertTrue(app.profilePage().isProfileOpened());
app.profilePage().openSettings();
assertTrue(app.settingsPage().isSettingsOpened());
app.settingsPage().clickNotificationSettings();
assertTrue(app.notificationPage().isNotificationOpened());
assertTrue(app.notificationPage().isToggleOff());
}
PageObject Class
public void clickProfileIcon() {
waitForElementToBeClickable(profile_icon, 15);
profile_icon.click();
}
public boolean isDashboardOpened() {
try {
waitForElementToBeVisibleBy(By.id("toolbar"), 15);
return true;
} catch (NoSuchElementException e) { return false; }
}
@AndroidFindBy(id="toolbar")
private MobileElement toolbar;
@AndroidFindBy(xpath="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/"
+ "android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/"
+ "android.widget.FrameLayout/android.widget.FrameLayout[3]/android.widget.RelativeLayout/"
+ "android.widget.ViewAnimator/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/"
+ "android.widget.ScrollView/android.widget.RelativeLayout/android.widget.LinearLayout[1]/"
+ "android.widget.FrameLayout/android.view.ViewGroup/android.widget.ImageButton")
private MobileElement profile_icon;
Result
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: Located by Locator map: - native content: "By.chained({By.xpath: /hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout[3]/android.widget.RelativeLayout/android.widget.ViewAnimator/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.ScrollView/android.widget.RelativeLayout/android.widget.LinearLayout[1]/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ImageButton})" - html content: "by id or name "profile_icon"" (tried for 15 second(s) with 500 MILLISECONDS interval)
Aucun commentaire:
Enregistrer un commentaire