java - Run Demo Program using TestNG on Android Studio -


i new testng , tried run below code, doesnt seem work testng. below code opens calculator app using testng, how not working.

how demo program run using testng in android studio on appium server?

  1. this java file.
package com.example.apple.appiumapplication;     import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.remote.capabilitytype; import org.openqa.selenium.remote.desiredcapabilities; import org.openqa.selenium.remote.remotewebdriver; import org.testng.annotations.aftermethod; import org.testng.annotations.beforemethod; import org.testng.annotations.test; import java.net.malformedurlexception; import java.net.url; import java.util.concurrent.timeunit;  public class firsttest {      webdriver driver;      @beforemethod     public void setup() throws malformedurlexception {         // created object of desiredcapabilities class.         desiredcapabilities capabilities = new desiredcapabilities();          // set android devicename desired capability. set device name.         capabilities.setcapability("devicename", "mi phone");          // set browser_name desired capability. it's android in our case here.         capabilities.setcapability(capabilitytype.browser_name, "android");          // set android version desired capability. set mobile device's os version.         capabilities.setcapability(capabilitytype.version, "5.0.2");          // set android platformname desired capability. it's android in our case here.         capabilities.setcapability("platformname", "android");          // set android apppackage desired capability.         // com.android.calculator2 calculator application.         // set application's apppackage if using other app.         capabilities.setcapability("apppackage", "com.miui.calculator");         // set android appactivity desired capability.         // com.android.calculator2.calculator calculator application.         // set application's apppackage if using other app.      capabilities.setcapability("appactivity","com.miui.calculator.cal.calculatoractivity");          // created object of remotewebdriver set capabilities.         // set appium server address , port number in url string.         // launch calculator app in android device.         driver = new remotewebdriver(new url("http://127.0.0.1:4723/wd/hub"), capabilities);         driver.manage().timeouts().implicitlywait(15, timeunit.seconds);     }      @test     void testfirstcalculator() {          // click on delete/clr button clear result text box before running test.         //driver.findelements(by.xpath("//android.widget.button")).get(5).click();         //driver.findelement(by.id("com.miui.calculator:id/btn_7")).gettext();         driver.findelement(by.xpath("//android.widget.button[@text='8' , @index='1']")).click();         // click on number 2 button.         //driver.findelement(by.name("7")).click();         //driver.findelement(by.name("6")).click();          driver.manage().timeouts().implicitlywait(30, timeunit.seconds);     }      @aftermethod     public void end() {         driver.quit();     } } 
  1. this build.gradle file
apply plugin: 'com.android.application'  android {     compilesdkversion 26     buildtoolsversion "26.0.1"     defaultconfig {         applicationid "com.example.apple.appiumapplication"         minsdkversion 19         targetsdkversion 26         versioncode 1         versionname "1.0"         testinstrumentationrunner "android.support.test.runner.androidjunitrunner"         enter code here         jackoptions {             enabled true         }     }     buildtypes {         release {             minifyenabled false             proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro'         }     }     compileoptions {         sourcecompatibility javaversion.version_1_8         targetcompatibility javaversion.version_1_8     }      packagingoptions {         exclude 'meta-inf/dependencies.txt'         exclude 'meta-inf/license.txt'         exclude 'meta-inf/notice.txt'         exclude 'meta-inf/notice'         exclude 'meta-inf/license'         exclude 'meta-inf/dependencies'         exclude 'meta-inf/notice.txt'         exclude 'meta-inf/license.txt'         exclude 'meta-inf/dependencies.txt'         exclude 'meta-inf/lgpl2.1'     }      buildtypes {         release {             minifyenabled false             proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro'         }     } }  dependencies {     compile filetree(include: ['*.jar'], dir: 'libs')     androidtestcompile('com.android.support.test.espresso:espresso-core:2.2.2', {         exclude group: 'com.android.support', module: 'support-annotations'     })     compile 'com.android.support:appcompat-v7:26.+'     compile 'com.android.support.constraint:constraint-layout:1.0.2'     compile 'com.android.support:design:26.+'     testcompile 'org.testng:testng:6.10'     compile files('libs/cglib-nodep-3.2.4.jar')     compile files('libs/client-combined-3.5.3-nodeps.jar')     compile files('libs/commons-codec-1.10.jar')     compile files('libs/commons-exec-1.3.jar')     compile files('libs/commons-io-2.5.jar')     compile files('libs/commons-lang3-3.5.jar')     compile files('libs/commons-logging-1.2.jar')     compile files('libs/cssparser-0.9.23.jar')     compile files('libs/gson-2.8.0.jar')     compile files('libs/guava-23.0.jar')     compile files('libs/hamcrest-core-1.3.jar')     compile files('libs/htmlunit-2.27.jar')     compile files('libs/htmlunit-core-js-2.27.jar')     compile files('libs/htmlunit-driver-2.27.jar')     compile files('libs/httpclient-4.5.3.jar')     compile files('libs/httpcore-4.4.6.jar')     compile files('libs/httpmime-4.5.3.jar')     compile files('libs/java-client-5.0.0-beta1.jar')     compile files('libs/javax.servlet-api-3.1.0.jar')     compile files('libs/jetty-client-9.4.5.v20170502.jar')     compile files('libs/jetty-http-9.4.5.v20170502.jar')     compile files('libs/jetty-io-9.4.5.v20170502.jar')     compile files('libs/jetty-util-9.4.5.v20170502.jar')     compile files('libs/jna-4.1.0.jar')     compile files('libs/jna-platform-4.1.0.jar')     compile files('libs/junit-4.12.jar')     compile files('libs/neko-htmlunit-2.27.jar')     compile files('libs/phantomjsdriver-1.4.0.jar')     compile files('libs/sac-1.3.jar')     compile files('libs/serializer-2.7.2.jar')     compile files('libs/websocket-api-9.4.5.v20170502.jar')     compile files('libs/websocket-client-9.4.5.v20170502.jar')     compile files('libs/websocket-common-9.4.5.v20170502.jar')     compile files('libs/xalan-2.7.2.jar')     compile files('libs/xercesimpl-2.11.0.jar')     compile files('libs/xml-apis-1.4.01.jar') } 

thanks.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -