I am trying to do appium android automation using Java. Below is the code:
public class Main {
AppiumDriver driver;
@Before
public void setup() throws Exception{
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("platformVersion","4.4");
desiredCapabilities.setCapability("platformName","Android");
desiredCapabilities.setCapability("app","/PATH_TO_APK");
driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"),desiredCapabilities);
}
@After
public void tearDown(){
driver.quit();
}
@Test
public void firstTest(){
WebElement element = driver.findElementById("ELEMENT_ID");
element.click();
}
}
Below is the error
org.openqa.selenium.WebDriverException: Unable to parse remote response: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id","sessionId","id"]} and you sent ["desiredCapabilities","requiredCapabilities","capabilities"]
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'WGB01ML106163.local', ip: 'fe80:0:0:0:3e15:c2ff:febe:8ea0%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_131'
Driver info: driver.version: AndroidDriver
Has anyone seen this error before? Cant find anything on Google. Please help.
We also need to pass the "deviceName" in the capabilities.
Also, if you doing hybrid/native app testing in the mobile, we need to pass appPackage and appActivity also. So combining all the mandatory capabilities, overall desired capabilities will look similar to this.
Easy way to get appActivity/appPackage is contacting your developer. If not possible check this=>appActivity/appPackage
More details about various capabilities are available here.
https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md