MainMenu

Home Core Java Overview Maven Tutorials

Sunday, 9 April 2017

Automate Android Chrome Browser using Appium



For Video Tutorial : Move on Youtube Channel


Note : Select the playlist as per your need & move with number sequence


For Video : CLICK HERE


First of all connect your device with usb cable
Start appium
write & run the script
Scenarios :
Open the Andriod Chrome Browser
navigate to URL "www.way2testing.com"
Scroll the browser
click the link "appium tutorial with example"

import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class Appauto
{
@Test
public void g() throws MalformedURLException, InterruptedException
{
//create object of DesiredCapabilities class
DesiredCapabilities capabilities = DesiredCapabilities.android();
//set the capability to execute test in chrome browser
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, BrowserType.CHROME);
//set the capability of Andriod platform
capabilities.setCapability(MobileCapabilityType.PLATFORM, Platform.ANDROID);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Andriod");
//set the device name
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "7c94b480");
//set the andriod version
capabilities.setCapability(MobileCapabilityType.VERSION, "5.1");
//create object of URL class and specify the appium server address
URL url = new URL("http://127.0.0.1:4723/wd/hub");
WebDriver driver = new AndroidDriver(url, capabilities);
driver.get("http://www.way2testing.com");
Thread.sleep(5000);
JavascriptExecutor js = (JavascriptExecutor) driver;
//Scroll page down to 250px
js.executeScript("window.scrollBy(0,750)", "");
driver.findElement(By.linkText("Appium Tutorials with example")).click();
Thread.sleep(5000);
}
}

No comments:

Post a Comment