WebDriverio ReferenceError $未定义错误
我正在使用Appium使用WebDriverio编写一个简单的自动测试。我想访问Google.com,然后单击“登录”按钮。但是,我似乎无法使用 $ 选择器。这是我的代码:
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');
});
});
我一直遇到无法使用美元符号选择器的错误。我尝试在此处重新编写文档: http://appium.io/docs /en/commands/element/actions/click/
清楚地表明您必须使用美元符号选择器才能单击在元素上通过ID。
我确保注意我使用的ID是正确的,并将ID更改为屏幕上的另一个对象产生了相同的结果。
方案: referenceError:$ nordin(webdriverio)
我还尝试了此解决 我是无效的选择器错误。
任何帮助将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试以下代码。
Can you tried with below code.