I am new to Protractor. I am using Protractor to test both Angular and Non-Angular applications. My testing sequence would be
我是初学量角器的。我正在使用量角器来测试角和非角的应用。我的测试序列是
- Testing Non-Angular log-in pange
- 测试Non-Angular登录发泡
- Once logged in, Testing Angular Home Page.
- 登录后,测试角主页。
I tried the below scripts but it throws me an error.
我尝试了下面的脚本,但是它给我带来了一个错误。
Config.js
Config.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'firefox'
},
specs: ['spec1.js'],
jasmineNodeOpts: {
showColors: true
}
};
Spec1.js
Spec1.js
describe('angularjs homepage', function() {
it('Availity', function() {
browser.driver.get('https://qa-apps.availity.com/availity/web/public.elegant.login');
browser.driver.findElement(by.name('userId')).sendKeys('xxxx');
browser.driver.findElement(by.name('password')).sendKeys('yyyy');
browser.driver.findElement(by.id('loginFormSubmit')).click();
browser.driver.sleep(1);
browser.waitForAngular();
element(by.className('navbar-brand-availity')).click();
});
});
Any help on above issue is highly appreciated.
对于上述问题的任何帮助,我们都非常感谢。
2 个解决方案
#1
2
You have to have the sync off when you are working with the non-angular part and then, turn the sync on again after you are logged in. Something like:
当你在处理非角部分时,你必须关闭同步,然后,在你登录后再次打开同步。喜欢的东西:
describe('angularjs homepage', function() {
beforeEach(function () {
browser.ignoreSynchronization = true;
browser.driver.get('https://qa-apps.availity.com/availity/web/public.elegant.login');
browser.driver.findElement(by.name('userId')).sendKeys('xxxx');
browser.driver.findElement(by.name('password')).sendKeys('yyyy');
browser.driver.findElement(by.id('loginFormSubmit')).click();
browser.driver.sleep(1);
browser.ignoreSynchronization = false;
browser.waitForAngular();
});
it('Availity', function() {
element(by.className('navbar-brand-availity')).click();
});
});
#2
0
you can do login in your protractor configuration file (config.js), with the onPrepare
function e.g.
可以使用onPrepare函数(例如)登录量角器配置文件(config.js)。
exports.config = {
onPrepare: function () {
browser.baseUrl = browser.params.baseUrl;
browser.driver.get(browser.baseUrl + 'Account/Login');
browser.driver.findElement(by.id('UserName')).sendKeys('username');
browser.driver.findElement(by.id('Password')).sendKeys('PASSWORD');
browser.driver.findElement(by.id('Login')).sendKeys(protractor.Key.ENTER);
return browser.driver.wait(function () {
return browser.driver.getCurrentUrl().then(function (url) {
return /home/.test(url);
});
}, 90000);
},
};
#1
2
You have to have the sync off when you are working with the non-angular part and then, turn the sync on again after you are logged in. Something like:
当你在处理非角部分时,你必须关闭同步,然后,在你登录后再次打开同步。喜欢的东西:
describe('angularjs homepage', function() {
beforeEach(function () {
browser.ignoreSynchronization = true;
browser.driver.get('https://qa-apps.availity.com/availity/web/public.elegant.login');
browser.driver.findElement(by.name('userId')).sendKeys('xxxx');
browser.driver.findElement(by.name('password')).sendKeys('yyyy');
browser.driver.findElement(by.id('loginFormSubmit')).click();
browser.driver.sleep(1);
browser.ignoreSynchronization = false;
browser.waitForAngular();
});
it('Availity', function() {
element(by.className('navbar-brand-availity')).click();
});
});
#2
0
you can do login in your protractor configuration file (config.js), with the onPrepare
function e.g.
可以使用onPrepare函数(例如)登录量角器配置文件(config.js)。
exports.config = {
onPrepare: function () {
browser.baseUrl = browser.params.baseUrl;
browser.driver.get(browser.baseUrl + 'Account/Login');
browser.driver.findElement(by.id('UserName')).sendKeys('username');
browser.driver.findElement(by.id('Password')).sendKeys('PASSWORD');
browser.driver.findElement(by.id('Login')).sendKeys(protractor.Key.ENTER);
return browser.driver.wait(function () {
return browser.driver.getCurrentUrl().then(function (url) {
return /home/.test(url);
});
}, 90000);
},
};