Im trying to config appium server and run tests after the Server start i get exception
1st class for the appium server:
package base_class;
public class Start_Appium_Server {
@BeforeTest
public void StartAppiumServer() throws Exception {
AppiumDriverLocalService service;
service = AppiumDriverLocalService.buildService(
new AppiumServiceBuilder()
.usingDriverExecutable(new File(“C:/Appium/node.exe”))
.withAppiumJS(new File(“C:/Appium/node_modules/appium/bin/appium.js”))
.withLogFile(new File(“C:/Appiumlogfile/Appiumlogfiletxt.txt”))
.withIPAddress(“127.0.0.1”)
.usingPort(4725)
);
service.start();
System.out.println("Thread_Sleep End ");
Thread.sleep(10000);
if(service.isRunning())
{
System.out.println("service is running");
}
else
{
System.out.println("service is not running");
}
}
@Test
public void Appium_Server_test() throws Exception {
System.err.println("Appium server Test");
**i add the @test to verififcation **
2nd class is for android driver capa:
package base_class;
public class Main_Base_Class extends Start_Appium_Server {
public static AndroidDriver<WebElement> driver = null;
public void beforeSuite() throws IOException, Exception {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/data/local/tmp");
File app = new File(appDir, "app-debug.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("appPackage" ,"My package name from appinfo applcation ");
cap.setCapability("appActivity" ,"My appActivity name from appinfo applcation ");
cap.setCapability("platformName",Platform.ANDROID);
cap.setCapability("deviceName","**_Device name from adb device command ");_**
cap.setCapability("platformVersion","5.0.1");
cap.setCapability("app", app.getAbsolutePath());
cap.setCapability("noReset", true);
driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"),cap);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
//Application context
Set<String> contextNames = ((AppiumDriver<WebElement>) driver).getContextHandles();
for (String contextName : contextNames) { // contextName = NEW VALU contextNames
//contextNames Result for getContextHandles method
System.out.println(contextNames);
}
}
@Test
public void Main_Base_Test() throws Exception {
System.err.println(“Main Base Class”);
Both of the classes run sepratly without any problem
when i try to execute my test from other package i ger exception
package sanity_Test;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import org.openqa.selenium.WebElement;
import org.testng.annotations.Test;
import base_class.*;
public class Login_test extends Main_Base_Class {
@Test(priority=1)
public void Login_Sanity_User_Details_TestCase() throws Exception {
WebElement User_Emailֹ_Text_Area = driver.findElementById("...add my id from uiautomator tool ");
User_Emailֹ_Text_Area.click();
User_Emailֹ_Text_Area.clear();
User_Emailֹ_Text_Area.sendKeys("[email protected]");
System.out.println( "Email add ");
}
public void User_Password_Address() {
WebElement User_Password_Text_Box = driver.findElementById("add my id from uiautomator tool ");
User_Password_Text_Box.click();
User_Password_Text_Box.clear();
User_Password_Text_Box.sendKeys("222222");
driver.hideKeyboard();
System.out.println( "Password add ");
}
public void Login_process() throws Exception {
WebElement Login_Button = driver.findElementById("add my id from uiautomator tool ");
Login_Button.click();
Thread.sleep(2000);
System.out.println("Login pass");
}
public void Android_Alert_message() {
WebElement alert_dialogbox = driver.findElementById("add my id from uiautomator tool r");
if(alert_dialogbox.isDisplayed()){
WebElement allow_Button = driver.findElementById("add my id from uiautomator tool ");
allow_Button.click();
}
}
}
From the log file:
[TestNG] Running:
C:\Users\Ohad.Vaserman\AppData\Local\Temp\testng-eclipse–36183619\testng-customsuite.xml
e[36minfoe[39m: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
e[36minfoe[39m: Appium REST http interface listener started on 127.0.0.1:4725
e[36minfoe[39m: [debug] Non-default server args: {“address”:“127.0.0.1”,“port”:4725,“log”:“C:\Appiumlogfile\Appiumlogfiletxt.txt”}
e[36minfoe[39m: Console LogLevel: debug
e[36minfoe[39m: File LogLevel: debug
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[36minfoe[39m: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.4.16”,“revision”:“ae6877eff263066b26328d457bd285c0cc62430d”}}}
Thread_Sleep End
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 15.357 ms - 105e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.4.16”,“revision”:“ae6877eff263066b26328d457bd285c0cc62430d”}}}e[39m
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[36minfoe[39m: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.4.16”,“revision”:“ae6877eff263066b26328d457bd285c0cc62430d”}}}
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32mservice is running
200e[39me[90m 9.050 ms - 105e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.4.16”,“revision”:“ae6877eff263066b26328d457bd285c0cc62430d”}}}e[39m
Main Base Class
Appium server Test
PASSED: Main_Base_Test
PASSED: Appium_Server_test
FAILED: Login_Sanity_User_Details_TestCase
java.lang.NullPointerException
at sanity_Test.Login_test.Login_Sanity_User_Details_TestCase(Login_test.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
===============================================
Default test
Tests run: 3, Failures: 1, Skips: 0
===============================================
Default suite
Total tests run: 3, Failures: 1, Skips: 0
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@f438e: 7 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 9 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@163425a: 5 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@643faf: 8 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@75222b: 42 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@171769e: 32 ms