Hello,i very new to appium…i have followed tutorials and used the Testapp7 in the appium site
but i could not automate the app with the java code written in Eclipse.
Below is my code and Error
org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@SuppressWarnings(“unused”)
public class AppiumIOSDemoTest {
//private AppiumDriver idriver;
public IOSDriver driver;
@BeforeMethod
public void setup() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appium-version", "1.4.0");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "8.0");
capabilities.setCapability("deviceName", "iPhone 6");
capabilities.setCapability("platformName", "/Volumes/company/ProjectsiOs/TestApp.app");
capabilities.setCapability("app", "iOS");
// String appPath = "/Volumes/company/ProjectsiOs/TestApp7.1.app.zip";
//capabilities.setCapability("app", appPath);
driver.manage().timeouts().implicitlyWait(180,TimeUnit.SECONDS);
//driver.quit();
driver.close();
try {
System.out.println("running...");
driver = new IOSDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (SessionNotCreatedException e) {
System.out.println("still running...");
e.printStackTrace();
}
}
@AfterMethod
public void tearDown() {
if (driver != null)
driver.quit();
}
@Test
public void simpleTest() {
driver.findElementByName("TextField1").sendKeys("88");
driver.findElementByName("TextField2").sendKeys("888");
driver.findElementByName("ComputeSumButton").click();
int answer = Integer.parseInt(driver.findElementByName("Answer")
.getText());
Assert.assertEquals(answer, 976);
}
}
pom.xml
4.0.0
com.company.ProjectsiOS
appium-ios-tutorial
0.0.1-SNAPSHOT
jar
appium-ios-tutorial
http://maven.apache.org
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>LATEST</version>
<scope>test</scope>
</dependency>
Error
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects…
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building appium-ios-tutorial 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] — maven-resources-plugin:2.6:resources (default-resources) @ appium-ios-tutorial —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Volumes/Company/ProjectsiOs/appium-ios-tutorial/src/main/resources
[INFO]
[INFO] — maven-compiler-plugin:2.5.1:compile (default-compile) @ appium-ios-tutorial —
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] — maven-resources-plugin:2.6:testResources (default-testResources) @ appium-ios-tutorial —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Volumes/Company/ProjectsiOs/appium-ios-tutorial/src/test/resources
[INFO]
[INFO] — maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ appium-ios-tutorial —
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] — maven-surefire-plugin:2.12.4:test (default-test) @ appium-ios-tutorial —
[INFO] Surefire report directory: /Volumes/Company/ProjectsiOs/appium-ios-tutorial/target/surefire-reports
T E S T S
Running TestSuite
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@77468bd9
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@7791a895
Tests run: 4, Failures: 1, Errors: 0, Skipped: 2, Time elapsed: 1.038 sec <<< FAILURE!
setup(com.example.company.appium_ios_tutorial.AppiumIOSDemoTest) Time elapsed: 0.648 sec <<< FAILURE!
java.lang.NullPointerException
at com.example.company.appium_ios_tutorial.AppiumIOSDemoTest.setup(AppiumIOSDemoTest.java:35)
Results :
Failed tests: setup(com.example.company.appium_ios_tutorial.AppiumIOSDemoTest)
Tests run: 4, Failures: 1, Errors: 0, Skipped: 2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.393 s
[INFO] Finished at: 2015-06-22T12:40:13+05:45
[INFO] Final Memory: 13M/178M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project appium-ios-tutorial: There are test failures.
[ERROR]
[ERROR] Please refer to /Volumes/Company/ProjectsiOs/appium-ios-tutorial/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project appium-ios-tutorial: There are test failures.
Please refer to /Volumes/Company/ProjectsiOs/appium-ios-tutorial/target/surefire-reports for the individual test results.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.
Please refer to /Volumes/Company/ProjectsiOs/appium-ios-tutorial/target/surefire-reports for the individual test results.
at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:83)
at org.apache.maven.plugin.surefire.SurefirePlugin.writeSummary(SurefirePlugin.java:176)
at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:150)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:650)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:586)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
… 19 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException