量角器:在特定页面中,量角器的任何操作都不起作用



在使用reveal.js包的页面之前,我的量角器脚本运行良好。我不确定这是否是导致脚本失败的原因,但除此之外,代码库与脚本运行良好的其他页面相同。

注意:我尝试了大多数量角器操作(单击、高亮显示、waitForElement、toContain等(,但都不起作用。我只能通过在脚本中插入jQuery来点击链接。

代码:

let HighlightElement = function (el) {
return browser.executeScript("arguments[0].setAttribute('style', arguments[1]);", el.getWebElement(), "color: Red; border: 1px solid red;").
then(function (resp) {
browser.sleep(2000);
return el;
}, function (err) { });
}

let waitUntilElementPresent = function (visibilityOfObject, maxWaitTime) {
var EC = protractor.ExpectedConditions;
browser.manage().timeouts().implicitlyWait(2);
browser.wait(function () {
browser.manage().timeouts().implicitlyWait(3);
return visibilityOfObject.isDisplayed()
.then(
function (isDisplayed) {
browser.wait(EC.visibilityOf(visibilityOfObject), maxWaitTime, "Element taking more time to load");
browser.manage().timeouts().implicitlyWait(3);
return isDisplayed;
},
function (error) {
return false;
});
}, 100000);
}

ACTUAL CODE:
var homepage = new homePageObj();
utilities.waitUntilElementPresent(homepage.waitScreenText); //here the script is failing. It is just a simple script and it used to work in other pages but it doesn’t work only in some of the pages
utilities.HighlightElement(homepage.waitScreenText);
utilities.HighlightElement(homepage.startButton);
homepage.startButton.click();
Error:
Failed: Wait timed out after 120062ms

使用下面的jQuery,我可以点击,但我们需要为我们使用的每个java脚本明确地给出等待时间,这很耗时。我是自动化的初学者,请帮我解决问题。

browser.executeScript("document.getElementsByClassName('cc-button')[0].click()");

我的代码在证明"browser.waitForAngularEnabled(false(";在脚本的开头。

相关内容

最新更新