【发布时间】:2015-09-03 09:27:24
【问题描述】:
这是第二部分:Expect: does not get the actual value
我能够更好地重现它,所以我有什么:
expect((rfpPage.buttons.sendRequest).getAttribute('disabled')).toBe('true');
(rfpPage.inputs.firstName).sendKeys('Name');
(rfpPage.inputs.lastName).sendKeys('Surname');
(rfpPage.inputs.email).sendKeys('name@email.com');
(rfpPage.inputs.phone).sendKeys('1234312');
(rfpPage.inputs.company).sendKeys('Company');
(rfpPage.inputs.address).sendKeys('Leningrad Motorway');
(rfpPage.inputs.city).sendKeys('Moscow');
(rfpPage.inputs.postalCode).sendKeys('125171');
(rfpPage.inputs.eventName).sendKeys('Test Meeting');
expect((rfpPage.buttons.sendRequest).getAttribute('disabled')).toBe(null);
HTML: 未填写表格时:
<button type="submit" class="btn btn-lg btn-warning pull-right ng-binding" ng-disabled="!rfpForm.$valid || isWaitForRfp" disabled="disabled">Send Request
</button>
表格填写时:
<button type="submit" class="btn btn-lg btn-warning pull-right ng-binding" ng-disabled="!rfpForm.$valid || isWaitForRfp"> Send Request
</button>
应该发生什么:
- 正在填充所有必填字段。
- 发送请求按钮已启用(已从 DOM 中删除禁用的属性)
第二个期望失败说期望为空。
这个测试在本地 3-4 台机器上运行良好,在多个浏览器上的 browserstack 上运行几个月。
*NOW:当它通过 BrowserStack 上的 Jenkins 执行时开始失败。 如果我在远程桌面机器上本地运行这个测试(从 Jenkins 执行测试的地方)它仍然运行得很好。在本地的几台机器上它仍然可以正常运行。在 BrowserStack 上本地运行正常。 *
我这里有量角器 2.2.0 和 Jasmine 2.3.4
在我看来,控制流出了点问题,但实际上这是非常奇怪的东西,我确实想明确地等待这个属性被删除,因为它会有所帮助,但看起来它不是正确的解决方案。
第二个样本:
expect(contactInfoPage.selectors.contactInfoSection.companyName.isDisplayed()).toBe(false);
contactInfoPage.selectors.contactInfoSection.isCorporate.click();
expect(contactInfoPage.selectors.contactInfoSection.companyName.isDisplayed()).toBe(true);
点击前的DOM:
<input tabindex="11" type="text" ng-model="contactInfo.companyName" id="companyName" ng-required="isCorporateEvent" class="ng-valid-maxlength ng-touched ng-valid ng-valid-required" maxlength="80">
点击后的DOM:
<input tabindex="11" type="text" ng-model="contactInfo.companyName" id="companyName" ng-required="isCorporateEvent" class="ng-valid-maxlength ng-touched required ng-invalid ng-invalid-required" maxlength="80" required="required">
错误:期望真为假
【问题讨论】:
-
rfpPage.buttons.sendRequest是做什么的? -
@nilesh 它只是将 css 选择器发送到发送请求按钮:rfpPage.buttons.sendRequest = $('button[type="submit"]');
标签: selenium-webdriver jasmine protractor angularjs-e2e e2e-testing