package com.test;
import java.net.MalformedURLException;
import java.net.URL;
//import java.util.concurrent.TimeUnit;
import io.appium.java_client.AppiumDriver;
//import io.appium.java_client.MobileBy;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDeviceActionShortcuts;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidKeyCode;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
//import org.openqa.selenium.interactions.internal.TouchAction;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
//import io.appium.java_client.AppiumDriver;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
public class WoApp {
//private String host = “localhost”;
//private int port = 8889;
protected AppiumDriver<WebElement> driver;
Dimension winSize=driver.manage().window().getSize();
//winSize = driver.manage().window().getSize();
@Before
public void setUp() throws MalformedURLException {
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability("device", "Android");
dc.setCapability("deviceName", "Galaxy S5");
//dc.setCapability("deviceName", "320860514b6f6105");
dc.setCapability("platformVersion", "6.0.1");
dc.setCapability("platformName", "Android");
dc.setCapability(MobileCapabilityType.UDID, "4d0076284f2f5125");
//dc.setCapability("autoLaunch", "false");
//These two capabilities of the app is installed.
dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.syclo.agentry.client.sawater");// will change
dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "com.syclo.agentry.client.android.ui.builtin.StartupActivity");// will change
//If app is not installed and you have the apk or ipa file, give the following capability.
//dc.setCapability("app", "C:\\Users\\VA326764\\Downloads\\New\\AgentryAndroidClientSolution.apk");
//wait time for application to load1
dc.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "1000");
driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"),dc);
}
@Test
public void testUntitled() throws InterruptedException {
//This will make the driver wait for each element for at least 10 seconds. You can change it anywhere in the test.
//If is is not specified, the driver immediately fails the test f the element is not found.
Thread.sleep(5000);
//driver.manage().timeouts().implicitlyWait("10", TimeUnit.SECONDS);
//driver.findElement(By.xpath("//*[@id='UserIdEditText']")).click();
driver.findElementById("com.syclo.agentry.client.sawater:id/UserIdEditText").click();
driver.findElementById("com.syclo.agentry.client.sawater:id/UserIdEditText").sendKeys("sai");
driver.findElementById("com.syclo.agentry.client.sawater:id/PasswordEditText").sendKeys("sawater22");
driver.findElementById("com.syclo.agentry.client.sawater:id/OK_button").click();
driver.findElementById("com.syclo.agentry.client.sawater:id/dialog_ok").click();
//code to sync to dev
driver.findElementById("com.syclo.agentry.client.sawater:id/serverText").click();
driver.findElementById("com.syclo.agentry.client.sawater:id/serverText").sendKeys("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
driver.findElementById("com.syclo.agentry.client.sawater:id/serverText").sendKeys("https://sawdvsmp21:8082/SAPWMMx\n");
driver.findElementById("com.syclo.agentry.client.sawater:id/SS_OK_button").click();
//Explicit wait until the devise gets sync to dev server
WebDriverWait wait = new WebDriverWait(driver,1000000000);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("ccom.syclo.agentry.client.sawater:id/text")));
driver.findElementById("com.syclo.agentry.client.sawater:id/text").click();
driver.findElementByClassName("android.widget.ImageView").click();
driver.findElementsByClassName("android.widget.ImageView").get(0).click();
driver.findElementById("com.syclo.agentry.client.sawater:id/wizard_screen_cancel_button").click();
driver.findElementById("com.syclo.agentry.client.sawater:id/widgetContainer");
// code after high priority work order is assigned
driver.findElement(By.xpath("//*[@id='Address']")).click();
driver.findElementsByClassName("android.widget.Spinner").get(2).click();
driver.findElementById("com.syclo.agentry.client.android:id/text").click();
//device action back
driver.findElementsById("com.syclo.agentry.client.android:id/widgetContainer").get(0).click();
driver.findElementsByClassName("android.widget.Spinner").get(2).click();
boolean b=driver.findElementById("com.syclo.agentry.client.sawater:id/text").isEnabled();
if(b)
{
System.out.println("the Acknowledged button is enabled");
}
else
{
System.out.println("the Acknowledged button is disabled");
}
driver.findElementById("com.syclo.agentry.client.sawater:id/text").click();
}
@After
public void tearDown() {
driver.quit();
}
}
Was trying to run the above code but it is generating java.lang.NullPointerException
No Appium logs are generated for the above case
All that i got in appium is
Checking if an update is available
Update available to new version 1.4.16.1
Launching Appium server with command: C:\Program Files (x86)\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --app C:\Users\VA326764\Downloads\New\AgentryAndroidClientSolution.apk --platform-name Android --platform-version 23 --automation-name Appium --log-no-color
warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade!
info: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {“app”:“C:\Users\VA326764\Downloads\New\AgentryAndroidClientSolution.apk”,“address”:“127.0.0.1”,“logNoColors”:true,“platformName”:“Android”,“platformVersion”:“23”,“automationName”:“Appium”}
info: Console LogLevel: debug
can any one help me to move in this