Je suis nouveau à Protractor. Voici mon fichier de configurationproblèmes lors de tests de protractor
config
:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome'
},
specs: ['./protractor-tests/*.js'],
jasmineNodeOpts: {
showColors: true
}
}
Ici, j'ai un scénario où je teste la connexion où la connexion de l'utilisateur via Outlook et quand cliquez sur connexion redirige vers la page d'accueil.
test Login:
exports.login = function() {
describe('Login Test', function() {
beforeEach(function() {
browser.get('http://domain/login');
});
afterEach(function() {
browser.ignoreSynchronization = false;
});
it('It should redirect to outlook for auth', function() {
browser.ignoreSynchronization = true;
var currentUrl;
browser.getCurrentUrl().then(function(url) {
currentUrl = url;
}).then(function() {
browser.wait(function() {
return browser.getCurrentUrl().then(function(url) {
return url !== currentUrl;
});
});
}).then(function() {
setTimeout(function() {
var userName = element(By.xpath('/html/body/div[1]/header/div[1]/section/div[2]/apt-user-profile/div/div/button[1]/span/span'));
if (userName)
expect(browser.getCurrentUrl()).toContain('http://domain/home');
else
expect(browser.getCurrentUrl()).toContain('https://login.microsoftonline.com');
}, 10000);
});
});
it('It should login into the application and display user as Tom White', function() {
setTimeout(function() {
browser.driver.findElement(by.id('cred_userid_inputtext')).sendKeys('[email protected]');
browser.driver.findElement(by.id('cred_password_inputtext')).sendKeys('****');
browser.driver.findElement(by.id('cred_sign_in_button')).click();
var userName = element(By.xpath('/html/body/div[1]/header/div[1]/section/div[2]/apt-user-profile/div/div/button[1]/span/span'));
expect(userName.getText()).toEqual('Hello Tom White');
}, 10000);
});
});
}
Ces cas de test sont en fait fonctionne très bien, mais quand en page d'accueil, je dois également cliquer sur un élément qui me redirige vers une autre page, il échoue avec l'erreur
Failed: javascript error: document unloaded while waiting for result
tests à domicile:
var loginPage = require('./loginTest.js');
describe('Home Test', function() {
loginPage.login();
it('It should click product', function() {
var productMenu = element(By.xpath('/html/body/div[1]/headerdiv[1]/section/div[1]/apt-nav-bar/div/div[2]/div[2]/ul/li[2]/a/span'));
productMenu.click();
expect(browser.getCurrentUrl()).not.toEqual('http://domain/home');
expect(browser.getCurrentUrl()).toEqual('http://domain/products');
})
});
Toute aide serait très appréciée.
si je fais browser.sleep (5000) I m obtenir l'erreur a échoué: Erreur dans l'attente d'une synchronisation avec Protractor la page: « window.angular est définie –
réponse mise à jour.Veuillez voir ci-dessus. – demouser123