我对使用量角器是陌生的,甚至连简单的脚本都无法运行。
症状是填充“ field1”,然后脚本挂起。删除.sendKeys上的“ await”将导致脚本运行,但是如果我随后将“ if(await field2.isPresent()){”移至“ field1” sendKeys下方,则将再次仅填充“ field1”。
在我看来,问题似乎与诺言有关,但这只是一个猜测。我需要的是能够在脚本的任何位置进行.isPresent检查。显然,这是一个简化的示例,并且为了便于说明而完成。
角度版本6
allScriptsTimeout:30000, ... SELENIUM_PROMISE_MANAGER:否,
“黄瓜”:“ ^ 5.0.2”, “ cucumber-html-reporter”:“ ^ 4.0.4”, “茉莉花”:“ ^ 3.3.0”, “茉莉花芯”:“ 2.99.1”, “ jasmine-spec-reporter”:“ 4.2.1”, “量角器”:“ ^ 5.4.1”, “ protractor-cucumber-framework”:“ ^ 6.1.1”, “ protractor-html-screenshot-reporter”:“ 0.0.21”,
Given ('peek capture is running', {timeout: 30000}, async function () {
await browser.get('#/login');
let field1: ElementFinder = element(by.id('login-email'));
let field2: ElementFinder = element(by.id('login-password'));
let field3: ElementFinder = element(by.css('#theButton'));
if (await field1.isPresent()) {
if (await field2.isPresent()) {
await field1.sendKeys('theuser@the.org');
await field2.sendKeys('the password');
await field3.click();
await browser.sleep(1500);
}
}
return(null);
});
答案 0 :(得分:0)
您可以在量角器中使用ExpectedConditions
https://www.protractortest.org/#/api?view=ProtractorExpectedConditions
Given ('peek capture is running', {timeout: 30000}, async function () {
var EC = protractor.ExpectedConditions;
var input1 = element(by.id('login-email'));
var input2 = element(by.id('login-password'));
var btn = element(by.css('#theButton'));
browser.wait(EC.visibilityOf(input1), 10000);
input1.sendKeys('****');
browser.wait(EC.visibilityOf(input2), 10000);
input2.sendKeys('****');
browser.wait(EC.isClickable(btn), 10000);
btn.click();
})