java - Appium/TestNG Test shows TimeoutException even if the element is already visible -
i tried test "noreset" capability set "true" (user logged in) , these statements in test method @ 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 passes.
however, test fails when try add these statements in test (user has 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 how have timeoutexception when can see profile_icon on screen. tried changing wait duration still produce timeoutexception.
here 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://127.0.0.1:4723/wd/hub"), 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 element clickable: located 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.linearlayout1/android.widget.framelayout/android.view.viewgroup/android.widget.imagebutton})" - html content: "by id or name "profile_icon"" (tried 15 second(s) 500 milliseconds interval)
Comments
Post a Comment