I’m trying to automate my hybrid app with Appium 1.19.1. Host machine is macOS.
It seems I get WebView context correctly.
Q1. I cannot use command from docs. For example, I tried to get element with the command driver.elementsByCss as described here but I’ve got tge error “elementsByCss is not a function”.
OK, I got element using driver.findElement(‘css selector’, ‘.input-username’);
Q2. How to emulate user input to this element (it’s input type=“text”).
I have tried:
element.addValue(‘use unput’)
element.type(‘user input’)
element.sendKeys(‘user input’)
all mentioined commands above raises error ‘* is not a function’
What is wrong?
my code (index.js):
const wdio = require("webdriverio");
const opts = {
path: '/wd/hub',
port: 4723,
capabilities: {
platformName: "Android",
platformVersion: "8",
deviceName: "device",
appPackage: "com.myCompany.myApp",
appActivity: "com.rhomobile.rhodes.RhodesActivity",
automationName: "UiAutomator2",
autoWebview: true,
autoWebviewTimeout: 20000,
noReset: true
}
};
async function main() {
const driver = await wdio.remote(opts);
let contexts = await driver.getContexts();
await driver.switchContext(contexts[1]);
const element = await driver.findElement('css selector', '.input-username');
console.log('element', element);
await element.addValue("Hello world!") // << the issue here
driver.context('NATIVE_APP');
driver.quit() // stop webdrivage
}
main();