失败测试/Hellow.test.js(11.693s) 你好世界测试 ✕应该允许进入世界(11014ms)
●Hello world测试›应该允许进入Hello World
TypeError: Cannot read property 'sendKeys' of undefined
32 | await sleep(3000);
33 | var element = await driver.element('css','*[name="q"]');
> 34 | await element.sendKeys('Hello World');
| ^
35 |
36 | });
37 |
at Object.sendKeys (test/Hellow.test.js:34:21)
测试套件:1个失败,总共1个 测试:1个失败,总共1个 快照:共0个 时间:12.086秒 跑所有与/ test Hellow.test.js匹配的测试套件 npm ERR!代码ELIFECYCLE npm ERR! errno 1 npm ERR!退出状态1 npm错误!
我正在运行的代码是
jest.setTimeout(60000);
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
describe('Hello world test', () => {
var wd = require('wd');
var driver;
var desiredCaps;
beforeAll(() => {
desiredCaps = {
browserName: 'chrome',
deviceName: 'Nexus 4',
platformName: 'Android',
appiumVersion: '1.13.0',
automationName: 'uiautomator2'
};
driver = wd.remote("http://0.0.0.0:4723/wd/hub");
});
it('should allow to enter hello world', async () => {
await driver.init(desiredCaps);
await sleep(8000);
await driver.get("http://www.google.com/");
await sleep(3000);
var element = await driver.element('css','*[name="q"]');
await element.sendKeys('Hello World');
});
});`