Mocking and Stubbing with protractor

This blog post discusses advance usage scenarios for Protractor. In particular it covers the the little know addMockModule() method of the Protractor browser object. The method allows you to create angular modules in Protractor (i.e. mocks or stubs of your API module) and upload them to the browser to replace the real implementation within the … Read more

How to debug timed out waiting for asynchronous Angular tasks? Failure to find elements on angular page occurring

In the following I list a set of potential causes and possibilities to fix/resolve them. How does AngularJS and Angular(2) Work / What can I check in the Browser Dev Mode I can’t explain it as well as Andrey Agibalov in his Blog here, so check it out (also for developers). Basically, the objects required … Read more

Protractor: Scroll down

You need to wait for the promise to be solved. The following example comes from an open issue browser.executeScript(‘window.scrollTo(0,0);’).then(function () { page.saveButton.click(); }) Update: This is an old question (May of 2014), but still it is getting some visitors. To clarify: window.scrollTo(0, 0) scrolls to the top left corner of the current page. If you … Read more

Timed out waiting for asynchronous script result while executing protractor scripts with appium

1. Regarding with route check In case after first spec, user got logged in and the route changed. Make sure all are navigated before any test executed. expect(browser.getCurrentUrl()).toContain(‘#/the_route_of_logged_in’); // ‘#/’ is just illustration. You can remove it to make it shorter // => like this …toContain(‘the_route_of_logged_in’); 2. Regarding with click on tutorial browser.wait(EC.elementToBeClickable(tutorial), 10000); Do … Read more

Non-angular page opened after a click

You can set ignoreSynchronization to be false once your verification is done. However, note that ignoreSynchronization is synchronous while everything else (click/get/etc) is asynchronous, so you need to be careful with that. Probably the safest way is to set it to true in beforeEach and false in afterEach, and just test that single logo click … Read more

Click() function isn’t working in protractor scripts

There might be multiple reasons for that and it is going to be a guessing game anyway. it could be that there is an another element matching the .login-button locator and you are clicking a different element. Let’s improve the locator: element(by.css(“.login-form .login-button”)).click(); wait for the element to be clickable: var EC = protractor.ExpectedConditions; element(by.model(‘credentials.username’)).sendKeys(‘RET02’); … Read more