I am trying to, after my app launches, to perform a tap/press action on a button element using an XPath selector. This app is a Hybrid app (native + some webviews).
I am having issues as the docs for Appium seem to be misleading (potentially).
getDriver():
const driver = await remote({
capabilities: {
platformName: 'IOS',
browserName: 'mobileOS',
deviceName: config.deviceName,
securityToken: config.securityToken,
app: 'PUBLIC:my-app.ipa'
},
hostname: config.hostname,
path: config.path,
port: config.port,
logLevel: config.logLevel
});
Here is how I get my driver up and running. This starts the device, and opens up the application that I install.
I try and perform a tap or press or click action:
const el = driver.$('//*[@name="MyButton"]');
driver.touchPerform([
{ action: 'press', options: { element: el } },
{ action: 'release'}
]);
The error I get is: Request failed due to java.util.LinkedHashMap cannot be cast to java.lang.String
or
const el = driver.$('//*[@name="MyButton"]');
driver.touchPerform(
{ action: 'tap', options: { element: el } }
);
The error I get is: Error getting WebDriver: Malformed type for "actions" parameter of command touchPerform Expected: object[] Actual: object
Now originally, I follow this doc: http://appium.io/docs/en/commands/interactions/touch/tap/ and/or http://appium.io/docs/en/commands/interactions/touch/touch-perform/
Now I may understand why the touchPerform( press ) may not work due to it specifying on other docs that it can only use x,y potentially.
But the tap is what is throwing me off. If I wrap the object I send in driver.touchPerform in an array like so:
const el = driver.$('//*[@name="MyButton"]');
driver.touchPerform([
{ action: 'tap', options: { element: el } }
]);
I get the same error as the previous: Request failed due to java.util.LinkedHashMap cannot be cast to java.lang.String
My question is, am I using the wrong selection or touch type event to click on a button on a mobile device?
I have also tried the http://appium.io/docs/en/commands/element/actions/click/ method, and when I try that it tells me driver.$(..).click() is not a function
Any help is greatly appreciated.