A sample mobile automation code for beginners.Code is for android platform.
App used is Komoot easily available on playstore or click here
Requirements:
Appium, Appium java Client,Selenium Jar file,Ui automated Viewer,Android SDK,
Komoot apk.
Click here for sample Pl/SQL code
package appium;
import io.appium.java_client.AppiumDriver;
import java.net.MalformedURLException ;
import io.appium.java_client.android.AndroidDriver;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
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.firefox.FirefoxDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.io.File;
import java.net.URL;
import java.sql.Driver;
public class testclass {
AppiumDriver driver;
public void setup()throws MalformedURLException{
DesiredCapabilities capabilities=new DesiredCapabilities();
capabilities.setCapability("devicename","Emulator");
capabilities.setCapability(CapabilityType.PLATFORM,"Android");
capabilities.setCapability("platformVersion","6");
capabilities.setCapability("browsername","android");
File file = new File("/home/kopite/prashant","Komoot-—-Cycling--Hiking-Maps_v9.0.10pakage.apk");
capabilities.setCapability("app",file.getAbsolutePath());
driver = (AppiumDriver) new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
}
@After public void tearDown(){
driver.quit();
}
public void TestMethod(){
MobileElement loginLink = driver.findElement(By.id("de.komoot.android:id/textview_login"));
loginLink.click();
}
}
No comments:
Post a Comment