我正在进行一些测试并创建用户。由于它连接到后端并创建真实用户,因此我需要固定装置(fixtures)。我想使用浏览器名称来创建唯一的用户。然而,获取它已被证明相当困难...
有人能指导我正确的方向吗?
我正在进行一些测试并创建用户。由于它连接到后端并创建真实用户,因此我需要固定装置(fixtures)。我想使用浏览器名称来创建唯一的用户。然而,获取它已被证明相当困难...
有人能指导我正确的方向吗?
另一个 橡皮鸭调试 的案例 :)
答案实际上非常简单。
在我的 onPrepare 函数中,我添加了以下函数,现在它可以完美地工作了。
browser.getCapabilities().then(function (cap) {
browser.browserName = cap.caps_.browserName;
});
browser.browserName
来获取我的测试中的名称。从Protractor 3.2版本(selenium webdriver 2.52)开始,这个已经发生了变化。
现在应该调用以下方法:
browser.driver.getCapabilities().then(function(caps){
browser.browserName = caps.get('browserName');
}
it('User should see a message that he has already been added to the campaing when entering the same email twice', function () {
browser.getCapabilities().then(function (capabilities) {
browserName = capabilities.caps_.browserName;
platform = capabilities.caps_.platform;
}).then(function () {
console.log('Browser:', browserName, 'on platform', platform);
if (browserName === 'internet explorer') {
console.log('IE Was avoided for this test.');
} else {
basePage.email.sendKeys('bruno@test.com');
console.log('Mande el mail');
basePage.subscribe.click().then(function () {
basePage.confirmMessage('Contact already added to target campaign');
});
}
});
});