Friday, 14 September 2018

findElement after switching webviews not working

I have a simple Espresso test for Android that works okay until the Activity is switched. The test runs through a login, selecting elements from a webview by class and then after a successful login, the activity switches. Once in the new Activity, I am unable to find anything in the new webview, either by class, css selector or by x_path.

I know this is buried in the html, I can see it and search for it in the chrome insepctor:

<div _ngcontent-c9="" class="tile-title" title="Pay">Pay </div>

Yet I can't find it with this CSS_SELECTOR:

onWebView(allOf<View>(isDisplayed(), isJavascriptEnabled()))
                    .withElement(findElement(Locator.CSS_SELECTOR, "div[title=Pay]"))

Similarly, I have also tried with an X_PATH string and even by class name (which is not unique) but it still fails.

We do have multiple webviews created, but only one is visible.

What can I do to shed more light on this and figure out why I can't select the div in question?



from findElement after switching webviews not working

No comments:

Post a Comment