Import Org.openqa.selenium.by;import Org.openqa.selenium.webelement;import Org.openqa.selenium.remote.capabilitytype;import org.openqa.selenium.remote.desiredcapabilities;d Esiredcapabilities capabilities = new Desiredcapabilities (); Capabilities.setcapability (CapabilityType.BROWSER_NAME , "");//This sentence is not required capabilities.setcapability ("DeviceName", "Android Emulator"); Capabilities.setcapability (" Platformversion "," 4.4 "), Capabilities.setcapability (" PlatformName "," Android "); Capabilities.setcapability (" Apppackage "," Com.android.calculator2 "); Capabilities.setcapability (" Appactivity ",". Calculator "); Appiumdriver Driver = new Appiumdriver (New URL ("Http://127.0.0.1:4723/wd/hub"), capabilities);
Appium, need to modify this parameter in the following
Capabilities.setcapability ("DeviceName", "Android Emulator");
devicename: Type of phone or simulator used
iPhone Simulator
, iPad Simulator
, iPhone Retina 4-inch
, Android Emulator
, Galaxy S4
, and so on. On IOS, the value of this keyword must be using theinstruments -s devices
one of the available device names to get. On Android, this keyword does not work at this time.
Capabilities.setcapability ("DeviceName", "Android Emulator"); Here is the name of the linked device if you need to connect the real machine can ADB devices view the ID of the phone and then fill in the Android Emulator here
Appium is how to connect to Android real machine