无法使用Jasmine(量角器)定位元素

无法使用Jasmine(量角器)定位元素,jasmine,protractor,qa,browser-automation,Jasmine,Protractor,Qa,Browser Automation,登录页面是非角度页面,当用户登录时,他/她将被重定向到主页。主页正在使用angular 对于登录,我使用了 browser.ignoreSynchronization = true; var loginTxt = browser.driver.findElement(by.id("userNameInput")); var pwdTxt = browser.driver.findElement(by.id("passwordInput"));

登录页面是非角度页面,当用户登录时,他/她将被重定向到主页。主页正在使用angular

对于登录,我使用了

        browser.ignoreSynchronization = true;
        var loginTxt = browser.driver.findElement(by.id("userNameInput"));
        var pwdTxt = browser.driver.findElement(by.id("passwordInput"));
        var signInBtn = browser.driver.findElement(by.id("submitButton"));
        loginTxt.sendKeys("test1");
        pwdTxt.sendKeys("password!");
        signInBtn.click();
用户已成功登录, 我使用了以下代码与主页中的元素进行交互

        browser.ignoreSynchronization = false;
        var el = element(by.className("btn item-desktop-only inactive-btn"))
        el.click();
错误代码: 信息: 失败:等待量角器与页面同步时出错:“angularJS可测试性和角度可测试性都未定义。这可能是因为这是一个非角度页面,或者因为您的测试涉及客户端导航,这可能会干扰量角器的引导。有关详细信息,请参阅”

当我移除

browser.ignoreSynchronization = false;
然后我得到一个错误,如下所示:

Message:
    Failed: No element found using locator: By(css selector, .btn.item-desktop-only.inactive-btn)
  Stack:
    NoSuchElementError: No element found using locator: By(css selector, .btn.item-desktop-only.inactive-btn)
HTML是:

<button _ngcontent-vsd-c3="" class="btn item-desktop-only inactive-btn" type="button" ng-reflect-klass="btn item-desktop-only" ng-reflect-ng-class="[object Object]"><img _ngcontent-vsd-c3="" class="orders-icon" src="/assets/icons/orders-inactive.png" srcset="/assets/icons/orders-inactive@2x.png 2x,/assets/icons/orders-inactive@3x.png 3x"> Orders </button>
订单

从错误中可以看出,主页不是angular app>version 2

着手

browser.ignoreSynchronization = true;
你能检查一下定位器是否正确吗。请通过在开发工具中查找定位器来验证定位器

人员体验:angular app版本<2运行良好,具有
browser.ignoreSynchronization=true

请尝试等待定位器存在

您可以在量角器中使用预期条件

const EC = require('protractor').ExpectedConditions;
let elm = element(by.id('your id'));  
browser.wait(EC.presenceOf(e), 10000); //2nd parameter is the max timeout
expect(e.isPresent()).toBeTruthy();

从错误中可以看出,主页不是angular app>version 2

着手

browser.ignoreSynchronization = true;
你能检查一下定位器是否正确吗。请通过在开发工具中查找定位器来验证定位器

人员体验:angular app版本<2运行良好,具有
browser.ignoreSynchronization=true

请尝试等待定位器存在

您可以在量角器中使用预期条件

const EC = require('protractor').ExpectedConditions;
let elm = element(by.id('your id'));  
browser.wait(EC.presenceOf(e), 10000); //2nd parameter is the max timeout
expect(e.isPresent()).toBeTruthy();

I删除browser.ignoreSynchronization=false;和用户broswer.sleep(5000);它正在工作。我删除browser.ignoreSynchronization=false;和用户broswer.sleep(5000);它现在正在工作。