【发布时间】:2017-12-14 06:46:51
【问题描述】:
运行测试时,it 块正在执行,我得到了这个输出。
我无法理解的是为什么 npm 命令会出现错误退出?
3) GAMETRIBE CELL C WAP DOI - SUCCESS FLOW Webdriver should target and click the subscription CTA:
An element could not be located on the page using the given search parameters ("[class='button']").
running phantomjs
Error: An element could not be located on the page using the given search parameters ("[class='button']").
at getText() - index.js:312:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webdriver_typescript@1.0.0 test-cellc: `node ./node_modules/typescript/lib/tsc.js && node ./node_modules/webdriverio/bin/wdio ./dist/wdio.conf.mcm.js --suite cellcWapDoi`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webdriver_typescript@1.0.0 test-cellc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/davidabes/.npm/_logs/2017-12-14T06_44_07_155Z-debug.log
我的测试用例如下所示:
export default function() {
it('Webdriver should target and click the subscription CTA', function() {
const yesLink = browser.element("[class='button']");
console.log(yesLink.getText());
console.log(yesLink.getTagName());
yesLink.click();
});
【问题讨论】:
-
只是出于好奇,你为什么不用
browser.element('.button')而不是[class="button"]? -
因为它没有找到所需的元素([class='button'])。这是预期的行为。您应该在对其执行任何操作之前添加 browser.waitForVisible() 命令。
标签: webdriver-io