I cannot get my .click() to work on my button, I get the error - element.click is not a function. Can anyone help?
The element renders ok, but click() is undefined.
const wd = require("wd");
const jasmine = require("jasmine");
const chai = require("chai");
jasmine.DEFAULT_TIMEOUT_INTERVAL = 600000;
const PORT = 4723;
const config = {
platformName: "iOS",
platformVersion: "10",
deviceName: "iPhone 11",
app: "./apps/myracnative.app",
udid: "4F94755B-6323-46B0-ACB4-469FB50BAD95",
automationName: "XCUITest", // UiAutomator2, Espresso, or UiAutomator1 for Android
};
const driver = wd.promiseChainRemote("localhost", PORT);
before(async () => {
await driver.init(config);
await driver.sleep(10000); // wait for app to load
});
it("login button will be clicked", async () => {
const element = await driver.hasElementByAccessibilityId("Log in");
await driver.sleep(200);
await element.click(); // element.click is not a function
});
My appium log shows it can find the element, but there is no mention of the click function:
[debug] [MJSONWP (30b7999b)] Calling AppiumDriver.findElements() with args: [“accessibility id”,“Log in”,“30b7999b-7759-4a19-9fea-518be038f7a3”]
[debug] [XCUITest] Executing command ‘findElements’
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id, css selector
[debug] [BaseDriver] Waiting up to 0 ms for condition
[debug] [WD Proxy] Matched ‘/elements’ to command name ‘findElements’
[debug] [WD Proxy] Proxying [POST /elements] to [POST http://127.0.0.1:8100/session/5C2E0576-602A-41E5-A7CE-37467D87C7B9/elements] with body: {“using”:“accessibility id”,“value”:“Log in”}
[debug] [WD Proxy] Got response with status 200: {“value”:[{“ELEMENT”:“25000000-0000-0000-8E1D-000000000000”,“element-6066-11e4-a52e-4f735466cecf”:“25000000-0000-0000-8E1D-000000000000”},{“ELEMENT”:“2A000000-0000-0000-8E1D-000000000000”,“element-6066-11e4-a52e-4f735466cecf”:“2A000000-0000-0000-8E1D-000000000000”}],“sessionId”:“5C2E0576-602A-41E5-A7CE-37467D87C7B9”}
[debug] [MJSONWP (30b7999b)] Responding to client with driver.findElements() result: [{“element-6066-11e4-a52e-4f735466cecf”:“25000000-0000-0000-8E1D-000000000000”,“ELEMENT”:“25000000-0000-0000-8E1D-000000000000”},{“element-6066-11e4-a52e-4f735466cecf”:“2A000000-0000-0000-8E1D-000000000000”,“ELEMENT”:“2A000000-0000-0000-8E1D-000000000000”}]
[HTTP] <-- POST /wd/hub/session/30b7999b-7759-4a19-9fea-518be038f7a3/elements 200 198 ms - 329
[HTTP]