android.support.test.espresso.web.webdriver.Locator Java Examples
The following examples show how to use
android.support.test.espresso.web.webdriver.Locator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebViewActivityTest.java From testing-cin with MIT License | 6 votes |
@Test public void typeTextInInput_clickButton_SubmitsForm() { // Lazily launch the Activity with a custom start Intent per test mActivityRule.launchActivity(withWebFormIntent()); // Selects the WebView in your layout. If you have multiple WebViews you can also use a // matcher to select a given WebView, onWebView(withId(R.id.web_view)). onWebView() // Find the input element by ID .withElement(findElement(Locator.ID, "text_input")) // Clear previous input .perform(clearElement()) // Enter text into the input element .perform(DriverAtoms.webKeys(MACCHIATO)) // Find the submit button .withElement(findElement(Locator.ID, "submitBtn")) // Simulate a click via javascript .perform(webClick()) // Find the response element by ID .withElement(findElement(Locator.ID, "response")) // Verify that the response page contains the entered text .check(webMatches(getText(), containsString(MACCHIATO))); }
Example #2
Source File: WebViewActivityTest.java From testing-cin with MIT License | 6 votes |
@Test public void typeTextInInput_clickButton_ChangesText() { // Lazily launch the Activity with a custom start Intent per test mActivityRule.launchActivity(withWebFormIntent()); // Selects the WebView in your layout. If you have multiple WebViews you can also use a // matcher to select a given WebView, onWebView(withId(R.id.web_view)). onWebView() // Find the input element by ID .withElement(findElement(Locator.ID, "text_input")) // Clear previous input .perform(clearElement()) // Enter text into the input element .perform(DriverAtoms.webKeys(DOPPIO)) // Find the change text button. .withElement(findElement(Locator.ID, "changeTextBtn")) // Click on it. .perform(webClick()) // Find the message element by ID .withElement(findElement(Locator.ID, "message")) // Verify that the text is displayed .check(webMatches(getText(), containsString(DOPPIO))); }
Example #3
Source File: LocalWebViewTest.java From aws-device-farm-sample-app-for-android with Apache License 2.0 | 5 votes |
/** * Enters a full name and then asserts if it's displayed * * @param firstName the entered first name * @param lastName the entered last name */ private void assertName(String firstName, String lastName) { typeIntoWebField(FIRST_NAME_FORM_ID, firstName); typeIntoWebField(LAST_NAME_FORM_ID, lastName); onWebView().withElement(findElement(Locator.ID, FULL_NAME_DISPLAY_ID)). check(webMatches(getText(), containsString(firstName + " " + lastName))); }
Example #4
Source File: SignInActivityTests.java From android-java-snippets-sample with MIT License | 4 votes |
public static void AzureADSignIn(String username, String password, ActivityTestRule<SignInActivity> signInActivityTestRule) throws InterruptedException { SignInActivity signInActivity = signInActivityTestRule.launchActivity(null); onView(withId(R.id.o365_signin)).perform(click()); try { onWebView() .withElement(findElement(Locator.ID, USER_ID_TEXT_ELEMENT)) .perform(clearElement()) // Enter text into the input element .perform(DriverAtoms.webKeys(username)) // Set focus on the username input text // The form validates the username when this field loses focus .perform(webClick()) .withElement(findElement(Locator.ID, PASSWORD_TEXT_ELEMENT)) // Now we force focus on this element to make // the username element to lose focus and validate .perform(webClick()) .perform(clearElement()) // Enter text into the input element .perform(DriverAtoms.webKeys(password)); Thread.sleep(2000, 0); onWebView() .withElement(findElement(Locator.ID, SIGN_IN_BUTTON_ELEMENT)) .perform(webClick()); } catch (NoMatchingViewException ex) { // If user is already logged in, the flow will go directly to SnippetListActivity } finally { Thread.sleep(2000, 0); } // Finally, verify that SnippetListActivity is on top intended(allOf( hasComponent(hasShortClassName(".SnippetListActivity")), toPackage("com.microsoft.graph.snippets") )); signInActivity.finish(); }
Example #5
Source File: LocalWebViewTest.java From aws-device-farm-sample-app-for-android with Apache License 2.0 | 2 votes |
/** * Types a given string into a id * * @param id the element id * @param text the text input */ private void typeIntoWebField(String id, String text){ onWebView().withElement(findElement(Locator.ID, id)).perform(clearElement()).perform(webKeys(text)); }