【发布时间】:2018-04-24 05:50:06
【问题描述】:
在执行期间,无法使用元素中的 @ 符号链接定位器。
错误:无法使用 xpath 定位元素:“@queryInput”
代码:
import * as config from 'config';
import { NightWatchClient, PageObject } from 'nightwatch';
const pageConfig = config.get<IPageConfig>('pages.google');
const page: PageObject = {
url: pageConfig.url,
elements: {
queryInput: {
selector: '//input[@name="q"]',
locateStrategy: 'xpath'
}
},
commands: [
{
enterQuery: (client: NightWatchClient, query: string) => {
return client
.waitForElementVisible('//input[@name="q"]', 5000)
//.setValue('//input[@name="q"]', [query, client.Keys.ENTER])
.setValue('@queryInput', [query, client.Keys.ENTER])
.waitForElementVisible('//*[@id="res"]', 5000);
},
},
]
};
export = page;
填写code
【问题讨论】:
标签: javascript typescript automated-tests nightwatch.js pageobjects