i have pageobject startpage have login , logout method. login method works fine , executed in @beforescenario:
@beforescenario public void login() { // {..} declaration of baseurl,user,password... homevm.setdefaultbaseurl(baseurl); homevm.open(); homevm.login(user, password); } and login(user,password) in class homevm like:
typeinto(find(by.id(getuserfieldid())), user); typeinto(find(by.id(getpasswordfieldid())), password); findby(getloginbuttonxpath()).then().click(); so nothing special, works fine. switch through several pageobjects in different test steps without problem. when code reaches @afterscenario looks like:
@afterscenario public void logout() { homevm.logoff(); } and class homevm method logoff() looks like:
webelement btnlogout = getdriver().findelement(by.xpath("//a [contains(@class,'lnklogout')]")); btnlogout.click(); but isn't working (nothing happens, no exception, no click.. nothing). tried log information getdriver() with:
system.out.println("windowhandles:"+getdriver().getwindowhandles().size()); system.out.println("title: "+getdriver().gettitle()); and both values empty (""). seems getdriver() empty (not null, don't nullpointerexception). why so? tried check getdriver() last pageobject used in test there information need, getdriver() in @afterscenario empty. idea or solution next or why happening? i'm using chromedriver.
edit: okay, recognized unexpected: have assertthat(<something>) method in last step , step producing assignment failure (because behaviour not implemented yet)... , if comment assertthat() out, @afterscenario , logout executed correctly. webdriver gets "emptied" if test fails? on purpose?
edit2: if catch assertionerrorexception exception test runs fine again of course test marked "test passed". has if exception thrown current webdriver gets emptied. seems wrong...
once serenity (or thucydides in case) spots test failure (e.g. assertion error), test switched "dry-run" mode, considers subsequent steps compromised , may result in unnecessary (and slow) web driver calls.
Comments
Post a Comment