Issue
I'm creating some automated web mobile app tests , using appium with Java. And I'm using genymotion emulator. I'm setting some capabilities, like
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "TheDeviceName");
But I'm not sure about the device name, from cmd when I type adb devices -l I get :
>adb devices -l
List of devices attached
192.168.54.101:5555 device product:vbox86p model:AminaPhone device:vbox86p
This is the code i used :
package com.example;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
public class FirstAppiumTest {
// create instance for appium driver
AppiumDriver<WebElement> driver;
@Test
public void Setup() throws MalformedURLException, InterruptedException
{
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.BROWSER_NAME,BrowserType.CHROME);
cap.setCapability(MobileCapabilityType.PLATFORM,Platform.ANDROID);
cap.setCapability(MobileCapabilityType.PLATFORM_NAME,MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.DEVICE_NAME,"Android");
//cap.setCapability("udid","192.168.54.101:5555");
//cap.setCapability("AVD", "emulator-5554");
driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub/status"), cap);
driver.get("http://www.facebook.com");
System.out.println("Title "+driver.getTitle());
System.out.println("SetUp is successful and Appium Driver is launched successfully");
driver.findElement(By.name("email")).sendKeys("[email protected]");
driver.findElement(By.name("pass")).sendKeys("test_selenium");
driver.findElement(By.id("u_0_5")).click();
//Thread.sleep(5000);
driver.quit();
}
}
What is the name that i should in the desiredcapabilities and in the appium configuration ? thank you.
Solution
Just to clarify: "adb devices" give you the device ID, not the device name. moreover, it's not possible to launch genymotion emulator directly from appium capabilities so you have to options:
If its important for you to also launch the emulator before test starts: https://stackoverflow.com/a/28961477/7368913
if it's not important to launch the emulator, simply add the capability:
cap.setCapability("udid, "192.168.54.101:5555");
Answered By - David Ep
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.