1

I'm using Appium to write a simple automated test with WebDriverIO. I want to visit Google.com, and click on the sign in button. However, I can't seem to be able to use the $ selector. Here's my code:

const webdriverio = require('webdriverio');
const androidOptions = require('../../helpers/caps').androidWebOptions;
const assert = require('chai').assert;
 
describe('Create Chrome web session', function () {
  let client;
 
  before(async function () {
    client = await webdriverio.remote(androidOptions);
  });
 
  after(async function () {
    return await client.deleteSession();
  });
 
  it('should create and destroy Android browser session', async function () {
    // Navigate to google.com
    const client = await webdriverio.remote(androidOptions);
    await client.url('https://www.google.com');
 
    const title = await client.getTitle();
 
    $('#4ca7df34-c02a-4b70-8318-8382f2318a4a').click()
 
    assert.equal(title, 'Google');
  });
});

I keep getting the error that the Dollar sign selector can't be used. I tried reffering tot he documentation here: http://appium.io/docs/en/commands/element/actions/click/

Which clearly shows that you have to use the dollar sign selector in order to click on an element via ID.

I made sure to note the ID I used was correct and changing the ID to another object on the screen yielded the same results.

I also tried this solution: ReferenceError: $ is not defined (WebdriverIO)

But that gives me an invalid selector error.

Any help would be appreciated.

0xI
  • 11
  • 3

1 Answers1

0

Can you tried with below code.

client.$('#4ca7df34-c02a-4b70-8318-8382f2318a4a').click()
Rupesh
  • 930
  • 7
  • 5