How to implement behaviour branches depending on GUI details in Android Espresso? -


in questions 21031556 (finding string espresso) , 23381459 (how text textview using espresso) recommended not read out value gui variable. in situation don´t find convincing solution:

in testcase, kernel testcase action has start in situation user not logged in. stable behavior want implement preparation, checking whether user logged in, , if so, perform logout; if not continue.

i can implement if-block, depending on variable:

    if (userisloggedin) {     // required actions perform logout     } 

i have text field shows “login” or username, , can perform assertion:

    textview.check(matches(withtext("login"))); 

to set variable, tried nest assertion within exception handler, variable set within handle method:

    userisloggedin = false; // member variable     viewinteraction logoutview = onview(         allof(childatposition(             allof(withid(r.id.left_drawer),                 withparent(withid(r.id.navigation_drawer))),                 0),             isdisplayed()));      logoutview.withfailurehandler(new failurehandler() {         @override         public void handle(throwable error, matcher<view> viewmatcher) {             userisloggedin = true;         }     }).check(matches(withtext("login"))); 

the handler accessed if check fails, required; variable set correctly. ending handle method, testcase execution aborts. if have empty handle method instead of variable assignment, execution continues after handle method, cannot control if-block.

instead of logout.check(), tried logout.perform(click()), exception handler, same effect.

now first non trivial testcase. assume further situations occur need implement different behaviors, depending of information find ba evaluating gui detail. how can implement this, without reading text variable?

thanks lot. gerhard


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -