Wednesday, September 5, 2018

Appium Tutorial - Type Inwards Text Box Of Android App

| Wednesday, September 5, 2018
Text box is really mutual chemical component division of whatever android native software app or software spider web application. In android appium software automation test, If y'all wants to type text inward text box of android app as well as hence y'all tin strength out role sendKeys(keysToSend) ascendance of selenium WebElement interface. Let's await at illustration to larn how to type inward text box of android app.

App To Use And Aim Of Test
We volition role API Demos software app inward this exam to larn how to type inward textbox of android application. 

 Text box is really mutual chemical component division of whatever android native software app or software spider web applic Appium Tutorial - Type In Text Box Of Android App

Above enshroud display text box. We volition role this text box to type text inward android appium software test. You tin strength out navigate to to a higher house enshroud from API Demos app's Home -> Views -> Controls -> 2. Dark Theme.

Create as well as hold upwards software test
Create bellow given exam inward eclipse as well as hold upwards it using testng as well as appium as well as divulge exam execution inward your android mobile screen.

TypeInTextBox.java
package Android;  import io.appium.java_client.android.AndroidDriver; import java.net.URL; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.remote.DesiredCapabilities; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test;  world degree TypeInTextBox {  AndroidDriver driver;   @BeforeTest  world void setUp() throws Exception {   DesiredCapabilities capabilities = novel DesiredCapabilities();   capabilities.setCapability("deviceName", "ZX1B32FFXF");   capabilities.setCapability("browserName", "Android");   capabilities.setCapability("platformVersion", "4.4.2");   capabilities.setCapability("platformName", "Android");   capabilities.setCapability("appPackage", "io.appium.android.apis");   capabilities.setCapability("appActivity","io.appium.android.apis.ApiDemos");   driver = novel AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);   driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);  }   @Test  world void typeInText() throws InterruptedException {   // Scroll till chemical component division which contains "Views" text If It Is non visible on screen.   driver.scrollTo("Views");   // Click on Views.   driver.findElement(By.name("Views")).click();   // Scroll till chemical component division which contains "Controls" text If It Is non visible on screen.   driver.scrollTo("Controls");   // Click on Controls.   driver.findElement(By.name("Controls")).click();   // Scroll till chemical component division which contains "2. Dark Theme" text If It Is non visible on screen.   driver.scrollTo("2. Dark Theme");   // Click on 2. Dark Theme.   driver.findElement(By.name("2. Dark Theme")).click();   // Typing inward text box using sendKeys command.   driver.findElement(By.id("io.appium.android.apis:id/edit")).sendKeys("Test");  }   @AfterTest  world void End() {   driver.quit();  } }

Last disputation of text method volition type text "Test" inward textbox of API Demos android app.

This means y'all tin strength out use sendKeys(keysToSend) ascendance to type text inward whatever text box of android software  application.

Related Posts