I'm using Appium with Selenium Webdriver to write automation test for my mobile application. When I trying to use if-else statement to check login status what the code shows follow:
beforeEach(function(){
if(client.element("~Get Started"))
{
return client
.init()
.element("~Get Started")
.click()
.element("~Primary Email")
.setValue("qa+appium@eventxtra.com")
.element("~Password")
.setValue("smartevent")
.element("~Log In").click()
}
else
{
return client
.init()
}
});
It works when the status is not login, which will show the element "Get Started", but when Logged in, the element "Get Started" cannot be detected, the condition of the if statement returns false, and the webdriver will count this as a test failure, how can I block this kind of error or how can I use the is-else statement in the framework properly?
Aucun commentaire:
Enregistrer un commentaire