App : NordVPN (https://play.google.com/store/apps/details?id=com.nordvpn.android)
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.touch.offset.PointOption;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.URL;
public class TestApp {
public static void main(String[] args) throws Exception {
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("noReset", "true");
desiredCapabilities.setCapability("deviceName", "S6");
desiredCapabilities.setCapability("udid", "03357df29a655b1f");
desiredCapabilities.setCapability("platformName", "Android");
desiredCapabilities.setCapability("platformVersion", "7.0");
desiredCapabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Appium");
desiredCapabilities.setCapability("appPackage", "com.nordvpn.android");
desiredCapabilities.setCapability("appActivity", ".MainActivity");
AndroidDriver androidDriver = new AndroidDriver(new URL("http://0.0.0.0:1111/wd/hub"), desiredCapabilities);
Thread.sleep(1000);
TouchAction touchAction = new TouchAction(androidDriver);
PointOption pointOption = new PointOption();
touchAction.press(pointOption.withCoordinates(929, 2097)).waitAction().moveTo(pointOption.withCoordinates(1005, 900)).release().perform();
Thread.sleep(1000);
androidDriver.findElement(By.xpath("//*[@text='Search']")).click();
Thread.sleep(1000);
androidDriver.findElementById("search_field").sendKeys("united states");
Thread.sleep(1000);
androidDriver.findElement(By.xpath("//*[@text='United States']")).click();
}
}
while executing “androidDriver.findElement(By.xpath(”//*[@text=‘United States’]")).click();" occurred
[AndroidBootstrap] [BOOTSTRAP LOG] [error] Error processing data to/from socket (java.net.SocketException: Software caused connection abort)
[UiAutomator] UiAutomator exited unexpectedly with code 1, signal null
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [AndroidDriver] Shutting down Android driver