Protractor times out waiting for sync with page when using $resource

Issue I’m testing Protractor with a small AngularJS app. This is the test: describe(‘Testing Protractor’, function() { var draftList; it(‘should count the number of drafts’, function() { browser.get(‘#/’); draftList = element.all(by.repeater(‘newsletter in drafts’)); expect(draftList.count()).toEqual(2); }); }); Controller: angular.module(‘myApp.controllers’, []). controller(‘DraftsCtrl’,

Continue reading

when running protractor with phantomjs browser, only able to run tests once

Issue test code: describe(‘mysite’, function(){ var init_url = ‘http://localhost/mySite/#/home’; beforeEach(function(){ // driver = new webdriver.Builder(). // withCapabilities(webdriver.Capabilities.phantomjs()).build(); }) it(‘should click on toolbox and do stuff’, function(){ browser.get(init_url); browser.waitForAngular(); browser.getCurrentUrl().then(function(url){ console.log(‘current_url’, url); expect(init_url).toEqual(init_url); }) expect(true).toBe(true); browser.sleep(2000); }) result 1st time run,

Continue reading

AngularJS E2E : Find element by tag name

Issue According to this link : https://docs.angularjs.org/api/ng/function/angular.element, the method “find()” allows to find an HTML element by tag name. I tried this in my code : element.find(‘button’).click(); And my HTML code is : <button ng-click=”getMessage()”>Request service as {{name}}</button> But the

Continue reading

protractor integration with IDE

Issue I have configured webstorm for using protractor, but when I launch my test suit, it does not recognize this param from my config file: // conf.js exports.config = { seleniumAddress: ‘http://localhost:4444/wd/hub’, specs: [‘spec.js’], capabilities: { browserName: ‘firefox’ } };

Continue reading

need protractor to wait for a service to return prior to testing

Issue I am relatively new to protractor, and I have not been able to make protractor to wait for a page to unload prior to testing. Example below: //in loginPage object function login(email, password) { element(by.id(‘inputEmail’)).sendKeys(email); element(by.id(‘inputPassword’)).sendKeys(password); element(by.css(‘.btn.btn-primary’)).click(); browser.driver.sleep(4000); return

Continue reading

Protractor e2e throwing webdriver is not defined

Issue I had my protractor running untill few days ago when i started encountering: Using the selenium server at http://localhost:4444/wd/hub **** UNCAUGHT EXCEPTION **** Error: connect ECONNREFUSED at exports._errnoException (util.js:682:11) at Object.afterConnect [as oncomplete] (net.js:947:19) **************************** **** UNCAUGHT EXCEPTION ****

Continue reading

Protractor get element by model in repeater array

Issue For example, in HTML page: <tr ng-repeat=”post in posts”> <td ng-click=”activePost(post)” class=”title”>{{post.title}}</td> <td><button class=”btn btn-danger” ng-click=”delete(post)”>Delete</button></td> <td><input type=”checkbox” ng-model=”post.active” id=”{{post.id}}” /></td> </tr> Then, I want something like: element.all(by.repeater(‘post in posts’)).then(function(posts) { var activePost = posts[0].element(by.model(‘active’)); expect(activePost).toEqual(true); }); This returns

Continue reading

How to identify page elements in protractor with no obvious identifiable property

Issue Background I have some (Angular JS template) HTML as follows: <div class=”data-handler-container”> <div class=”row”> <div class=”data-handler” ng-if=”dataController.showDistance()”> <p>{{ ‘Item Count’ | translate}} <p class=”metric”>{{dataController.project.item_total | converter:dataController.user.unit | number: 6}}<span class=”unit”>{{dataController.user.unit}}</span></p> </div> <div class=”data-handler”> <p>{{ ‘Total Time’ | translate}}</p> <p

Continue reading

Test comparison doesn't work as expected

Issue 1) I have the very strange mistake in my protractor code. And I don’t understand what may be reason of it. it(‘should filtering by interval correctly’, function () { filter_field.click(); var filter_field_text = filter_field.element(by.css(‘input’)); var exist_value1 = element(by.xpath(‘//tr[@data-row-index=”1″]/td[@data-column-index=”5″]/div’)).getText().then(function (value)

Continue reading

Protractor: functions overloading

Issue I try to extend ElementFinder library. I wondering how I can require different methods with the same names? I want to make something like: // spec.js var ef1 = require(‘./ef_extend1.js’); var ef2 = require(‘./ef_extend2.js’); expect(column_resizer.ef1.getWidth()).toEqual(18); expect(column_resizer.ef2.getWidth()).toEqual(18); Now I have

Continue reading

Protractor: can't add new method to return FindElement

Issue I want to extend FindElement and FindArrayElement libraries. Can I write something like: //ef_extend.js protractor.ElementFinder.prototype.getColumnList = function() { return this.all(webdriver.By.xpath(‘//td[@id=”SSW_1_0″]/..//tr[@class=”n-grid__head-row”]/th’)); }; And: var ps_grid = element(by.id(ps_grid_id)); var all_columns = ps_grid.getColumnList(); Now I always have error: TypeError: Invalid locator Stacktrace:

Continue reading

Mocking a server response

Issue I’m new to e2e testing. I’ve encountered problem during my protractor tests. My web application calls API despite my efforts: Started GET “/api/programs” for 127.0.0.1 at 2015-06-22 10:43:19 +0200 Processing by Api::V1::ProgramsController#index as JSON ======= NO Authorization token =======

Continue reading

Protractor: custom locators

Issue I have this code: by.addLocator(‘Name’, function(spanText, opt_parentElement) { var using = opt_parentElement || document; var td = using.querySelectorAll(‘td’); return Array.prototype.filter.call(td, function(teg) { return teg.getAttribute(“Name”) === spanText; }); }); It’s a simple method to search by attribute “Name”. But it

Continue reading

Error: Timed out waiting for Protractor to synchronize with the page after 11001ms." when user browser.getCurrentUrl()

Issue I am testing login and logout functionality, below is my test cases it(‘should redirect to login page on click of logout’,function(){ signInPage.email.sendKeys(‘zahid.afaque@meltwater.com’); signInPage.password.sendKeys(1234); signInPage.loginButton.click(); expect(browser.getCurrentUrl()).toMatch(/\/collections/); signInPage.profileImage.click(); signInPage.logout.click(); browser.waitForAngular(); expect(browser.getCurrentUrl()).toMatch(/\/login/); }); When i run above test its failing and below

Continue reading

Neither waitForAngular nor "then" work as expected

Issue I tried all variations mentioned in this Q&A: first one element(by.css(‘[ng-click=”vm.openNewPage()”]’)).click().then(function () { expect(element(by.css(‘[ng-click=”vm.submitButtonOfThatPage()”]’)).isPresent()).toBe(true); }); second one element(by.css(‘[ng-click=”vm.openNewPage()”]’)); browser.waitForAngular(); expect(element(by.css(‘[ng-click=”vm.submitButtonOfThatPage()”]’)).isPresent()).toBe(true); third one: element(by.css(‘[ng-click=”vm.openNewPage()”]’)); browser.sleep(1) browser.waitForAngular(); expect(element(by.css(‘[ng-click=”vm.submitButtonOfThatPage()”]’)).isPresent()).toBe(true); none of them passes test: Expected false to be true. except this one

Continue reading

Jasmine: Expect does not get actual value

Issue This is second part of: Expect: does not get the actual value I was able to reproduce it a little bit better, so what I have: expect((rfpPage.buttons.sendRequest).getAttribute(‘disabled’)).toBe(‘true’); (rfpPage.inputs.firstName).sendKeys(‘Name’); (rfpPage.inputs.lastName).sendKeys(‘Surname’); (rfpPage.inputs.email).sendKeys(‘name@email.com’); (rfpPage.inputs.phone).sendKeys(‘1234312’); (rfpPage.inputs.company).sendKeys(‘Company’); (rfpPage.inputs.address).sendKeys(‘Leningrad Motorway’); (rfpPage.inputs.city).sendKeys(‘Moscow’); (rfpPage.inputs.postalCode).sendKeys(‘125171’); (rfpPage.inputs.eventName).sendKeys(‘Test Meeting’); expect((rfpPage.buttons.sendRequest).getAttribute(‘disabled’)).toBe(null);

Continue reading

Space instead enter

Issue I try to simulate pressing key ENTER. But when I try to do it I have the same result like I pressed SPACE. And I don’t understand why it happens. My code: field.clear().click().sendKeys(“Hello”); browser.actions().sendKeys(protractor.Key.ENTER).perform(); I tryed: field.clear().click().sendKeys(“Hello”+”\n”); field.sendKeys(“Hello”,protractor.Key.ENTER).perform(); But

Continue reading