等待量角器与页面同步时出错:"Cannot read property 'get' of undefined"
Error while waiting for the protractor to sync with the page: "Cannot read property 'get' of undefined"
我的测试目标页面有SSO集成登录。一旦我点击该页面,SSO 集成 windows 身份验证将发生,然后定向到主页。
我试图关闭同步,第一次测试检查标题时它可以工作,但第二次测试时,它会 return 无法定位元素的错误,当我打开同步时,它会 return 不同步错误和未定义错误。
describe('Test area to ', function () {
var menuObjects = require('../page/MenuObjects.js');
it('Verify Page Title', function () {
menuObjects.setSyncOff();
browser.get('/home/');
expect(browser.getTitle()).toEqual('Home');
browser.driver.sleep(3000);
});
it('Navigate ', function () {
menuObjects.setSyncOn();
menuObjects.menuButton.click();
});
});
导航错误消息 - menuObjects.setSyncOn();
Error while waiting for Protractor to sync with the page: "Cannot read property 'get' of undefined"
导航错误消息 - menuObjects.setSyncOff();
NoSuchElementError: No element found using locator: By.id("menu-link")
ng-app
包含在div中body:
<body style="width: 100%">
<div class="frame" style="width: 100%">
<div class="container-fluid" style="width: 100%">
<div class="" style="width: 100%">
<div style="width: 100%">
<!--_AngularBaseLayout: BEGIN-->
<div ng-app="myHomeApp" ng-cloak class="ng-cloak">
<div ng-view id="ng-view"> </div>
</div>
有什么建议吗?
如果 ng-app
没有在 html
或 body
上定义,您需要通过设置 rootElement
configuration setting:[=21 让 protractor
知道它=]
exports.config = {
seleniumAddress: env.seleniumAddress,
baseUrl: env.baseUrl,
...
// Selector for the element housing the angular app.
rootElement: 'div#nested-ng-app'
};
这将使得没有必要打开和关闭同步 - 量角器将等待 angular "to settle down",然后再继续执行进一步的测试。
如果这对 NoSuchElementError
错误没有帮助,您可以在 presenceOf
"Expected Condition":
的帮助下明确等待元素出现
var EC = protractor.ExpectedConditions;
var elm = browser.wait(EC.presenceOf($('#menu-link')), 5000);
我的测试目标页面有SSO集成登录。一旦我点击该页面,SSO 集成 windows 身份验证将发生,然后定向到主页。
我试图关闭同步,第一次测试检查标题时它可以工作,但第二次测试时,它会 return 无法定位元素的错误,当我打开同步时,它会 return 不同步错误和未定义错误。
describe('Test area to ', function () {
var menuObjects = require('../page/MenuObjects.js');
it('Verify Page Title', function () {
menuObjects.setSyncOff();
browser.get('/home/');
expect(browser.getTitle()).toEqual('Home');
browser.driver.sleep(3000);
});
it('Navigate ', function () {
menuObjects.setSyncOn();
menuObjects.menuButton.click();
});
});
导航错误消息 - menuObjects.setSyncOn();
Error while waiting for Protractor to sync with the page: "Cannot read property 'get' of undefined"
导航错误消息 - menuObjects.setSyncOff();
NoSuchElementError: No element found using locator: By.id("menu-link")
ng-app
包含在div中body:
<body style="width: 100%">
<div class="frame" style="width: 100%">
<div class="container-fluid" style="width: 100%">
<div class="" style="width: 100%">
<div style="width: 100%">
<!--_AngularBaseLayout: BEGIN-->
<div ng-app="myHomeApp" ng-cloak class="ng-cloak">
<div ng-view id="ng-view"> </div>
</div>
有什么建议吗?
如果 ng-app
没有在 html
或 body
上定义,您需要通过设置 rootElement
configuration setting:[=21 让 protractor
知道它=]
exports.config = {
seleniumAddress: env.seleniumAddress,
baseUrl: env.baseUrl,
...
// Selector for the element housing the angular app.
rootElement: 'div#nested-ng-app'
};
这将使得没有必要打开和关闭同步 - 量角器将等待 angular "to settle down",然后再继续执行进一步的测试。
如果这对 NoSuchElementError
错误没有帮助,您可以在 presenceOf
"Expected Condition":
var EC = protractor.ExpectedConditions;
var elm = browser.wait(EC.presenceOf($('#menu-link')), 5000);