【发布时间】:2020-05-04 03:54:51
【问题描述】:
当函数这样定义时,一切正常,我的测试成功点击按钮(这里的代码是简化的,不是复制粘贴的,所以如果票证描述中有任何语法错误,那不是票证的答案):
const wdio = require("webdriverio");
const options = require('./android.conf.js').config;
describe('Main',async ()=> {
it('Should click button', async ()=> {
const client = await wdio.remote(options);
const button = await client.findElement('id', 'app.debug:id/theID');
await client.isElementDisplayed(button.ELEMENT).then(async () => {
await client.elementClick(button.ELEMENT);
})
})
但我这样描述 pageObject:
function PageObjects() {
this.clickButton = async (client)=> {
const button = await client.findElement('id', 'app.debug:id/theID');
await client.isElementDisplayed(button.ELEMENT).then(async () => {
await client.elementClick(button.ELEMENT);
});
}
};
module.exports = PageObjects;
我的功能是这样的:
const wdio = require("webdriverio");
const options = require('./android.conf.js').config;
const PageObjects = require('./po.js');
describe('Main', async ()=> {
const po = new PageObjects();
it('Should click button', async ()=> {
const client = await wdio.remote(options);
po.clickButton(client);
})
})
它停止工作,我的测试不能再点击按钮了!我做错了什么?
【问题讨论】:
标签: javascript appium pageobjects