I'm new on protractor, and I'm trying to implement an e2e test. I don't know if this is the right way to do this, but... The page that I want to test is not a full angular page based, so... I'm having some trouble.
On my first spec I have:
describe('should open contact page', function() {
var ptor = protractor.getInstance();
beforeEach(function(){
var Login = require('./util/Login');
new Login(ptor);
});
I have created this Login class, but after login I want to open the contact page, but protractor immediately try to find element before the page is fully loaded.
I've tried to use:
browser.driver.wait(function() {
expect(browser.findElement(by.xpath("//a[@href='#/contacts']")).isDisplayed());
ptor.findElement(by.xpath("//a[@href='#/contacts']")).click();
});
But it doesn't work... it always try to find the element before the page loads. I tried this one too:
browser.driver.wait(function() {
expect(ptor.isElementPresent(by.xpath("//a[@href='#/contacts']")));
ptor.findElement(by.xpath("//a[@href='#/contacts']")).click();
});
I'm able to do that using browser.sleep();
but I don't think that is a good option. Any idea? On my login class I have:
ptor.ignoreSynchronization = true;
How can I wait for this @href='#/contacts
before protractor tries to click on it?
describe
into a callback for theready
event, but I don't know this system and the test runner your are using, so maybe it won't work... – Caratbrowser.findElement(by.xpath("//a[@href='#/contacts']")).isDisplayed().then(function(){// do click() and other actions};
? – Cardiacptor = protractor.getInstance();
under thebeforeEach
orit
. I checked about 5-10 code, but nobody sets its value in the describe. Ofc. this is just a guess... I am still learning how to use that test environment... blog.busymachines.com/frontend/angularjs/testing/2013/10/28/… – Caratit(title, callback, msec)
function, so you don't have to write the timeout manually... – Caratprotractor.getInstance();
is not a function – Roca