How to access elements on external website using Espresso -
using espresso, click login button launches external website (chrome custom tab) can login , redirects our android application. there way in espresso to: 1) verify correct url being launched 2) access elements on website can enter login information , continue login
when try viewing in espresso launch navigator, nothing shows page, , if try record, doesn't pick on me entering on page.
this have far (it in kotlin (not java)): 
and here error gets displayed: 
it launches application, select login button, opens website isn't able access elements.
i tried:
update: using chrome custom tabs (not web view) espresso web not working.
update:
you can't use espresso testing chrome custom tabs. espresso works when testing own app.
for testing chrome tabs use ui automator don't want that.
1) verify correct url being launched
a unit test enough here. need make sure url passed chrome custom tabs library correct one. making sure code works fine. happens next handled library , tests belong there.
2) access elements on website can enter login information , continue login
here testing simple web page. why additional overhead of starting emulator? maybe selenium or whatever cool web work here (not web dev)?
you can use espresso web
here example test:
@test public void typetextininput_clickbutton_submitsform() { // lazily launch activity custom start intent per test. mactivityrule.launchactivity(withwebformintent()); // selects webview in layout. if have multiple webview objects, // can use matcher select given webview, // onwebview(withid(r.id.web_view)). onwebview() // find input element id. .withelement(findelement(locator.id, "text_input")) // clear previous input. .perform(clearelement()) // enter text input element. .perform(driveratoms.webkeys(macchiato)) // find submit button. .withelement(findelement(locator.id, "submitbtn")) // simulate click using javascript. .perform(webclick()) // find response element id. .withelement(findelement(locator.id, "response")) // verify response page contains entered text. .check(webmatches(gettext(), containsstring(macchiato))); } 

Comments
Post a Comment