简体   繁体   中英

Appium Automation: Getting error - org.openqa.selenium.WebDriverException: Unable to parse remote response: Parameters were incorrect

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.

 desiredCapabilities.setCapability("deviceName","Android");

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.

public void setup() throws Exception
{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","ANDROID");
capabilities.setCapability("platformVersion", "5.1");
capabilities.setCapability("platformName",Constant.appPlatform);
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", Constant.appPackage);
capabilities.setCapability("appActivity",Constant.appActivity);

driver = new AndroidDriver(new URL("http://127.0.0.1:4727/wd/hub"),capabilities);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Automation Testing Error : org.openqa.selenium.WebDriverException: disconnected: unable to connect to renderer Getting Error: org.openqa.selenium.WebDriverException: element not interactable Getting "org.openqa.selenium.WebDriverException: unknown error: session deleted because of page crash" error when executing automation scripts Integrating galen with appium and getting org.openqa.selenium.WebDriverException: Method is not implemented Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: unexpected command response using Selenium Java Error While launching appium browser:- org.openqa.selenium.WebDriverException: ERROR running Appium command: Arguments to path.resolve must be strings Getting an error org.openqa.selenium.WebDriverException disconnected: received Inspector.detached event with Selenium ChromeDriver and Chrome In Jenkins haedless browser :org.openqa.selenium.WebDriverException: Error communicating with the remote browser. It may have died Getting error : org.openqa.selenium.WebDriverException: unknown error: keys should be a string
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM