FAQ Database Discussion Community


Cloning element finders

javascript,testing,selenium,protractor,end-to-end
While researching available ElementFinder and ElementArrayFinder methods, I've noticed that there is a clone() method which is briefly documented: Create a shallow copy of ElementFinder. From what I understand, clone() is not coming from WebdriverJS and is a protractor-specific function. What I don't understand is why would you want to...

How do I identify checkbox value with given HTML element? angularjs-e2e

angularjs,testing,protractor,angularjs-e2e,end-to-end
I need some advice with issue below. When checkbox = checked, there will be attribute value checked=checked and for the unchecks, attribute will not be there and I can't uniquely identify. On a page, there will be checked and unchecked checkboxes. Dev refuses to add additional attribute for me and...

Cleanup for running spec files in series in Protractor

protractor,end-to-end
I am running multiple specs using a Protractor configuration file as follows: ... specs: [abc.js , xyz.js] ... After abc.js is finished I want to reset my App to an initial state from where the next spec xyz.js can kick off. Is there a well defined way of doing so...

Protractor: cleanup after test suite is finished

javascript,selenium,testing,protractor,end-to-end
In my "conf.js" test suites are arranged as follows(using saucelab's webdriver): suites: { abc: './abc/spec.js', xyz: './xyz/spec.js', pqr: './pqr/spec.js' }, The problem with above arrangement is if one of the alert box/window unexpectedly appears in one of the test suite,test suites after that particular suite suffer and start failing. Is...

protractor - switch to facebook login screen when testing Oauth2

testing,oauth-2.0,protractor,end-to-end,e2e-testing
I'm trying to write e2e login test to my application which uses oauth2. when clicking the facbook login- another window opened (the facebook login). I'm trying to enter the credentials there. I'm currently using browser.driver.switchTo().window(); because it is a new window. I've read that I can get the name of...

Testing tab navigation order

javascript,testing,selenium,protractor,end-to-end
In one of our tests, we need to make sure that the tab keyboard navigation inside a form is performed in the correct order. Question: What is the conventional way to check the tab navigation order with protractor? Currently we are solving it by repeating the following step for as...

Error while waiting for the protractor to sync with the page: “Cannot read property 'get' of undefined”

angularjs,testing,selenium-webdriver,protractor,end-to-end
My test target page has SSO integrated login. Once I hit the page, SSO integrated windows authentication will occur then directed to home page. I tried to turn Sync off and it works for first test to check title but for second test, it will return error unable to locate...

“More than one element found for locator” warning

angularjs,testing,warnings,protractor,end-to-end
In one of my tests, I'm locating an element using a CSS selector: element(by.css("ul.nav button")) There is more than one element matching the query, but, since I need only the first one, I'm okay with the selector. The problem is, protractor throws a warning: WARNING - more than one element...

Slider testing using protractor

angularjs,testing,protractor,end-to-end,e2e-testing
Very new to protractor, and trying to test a slider using protractor. I found: ptor.actions().dragAndDrop(slider.find(), {x:100, y:0}).perform() should do the work. But its not helping in my code, can some one suggest something here? The HTML code snippet: <input ng-model="sliderValue" type="text" id="slider" slider="" options="sliderOptions" class="ng-pristine ng-untouched ng-valid ng-isolate-scope ng-hide" value="60">...

Custom message on wait timeout error

testing,selenium,jasmine,protractor,end-to-end
From time to time I'm using "Expected Conditions" feature introduced in protractor 1.7. Use case: var EC = protractor.ExpectedConditions; browser.wait(EC.visibilityOf(header.displayName), 10000); where header is a Page Object. If header.displayName would not become visible in 10 seconds, an error would be thrown: [firefox #4] 2) Describe description here [firefox #4] Message:...

How to stop protractor from running further testcases on failure?

javascript,testing,jasmine,protractor,end-to-end
Is there a way of quitting test suite and stop executing further test cases, if a test case fails in protractor?

Insert value to div

javascript,angularjs,testing,protractor,end-to-end
I have HTML + Angular looks like this: <div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name" class="ui-grid-cell ng-scope ui-grid-coluiGrid-15T" ng-class="{ 'ui-grid-row-header-cell': col.isRowHeader }" ui-grid-cell=""> <div class="ui-grid-cell-contents ng-binding ng-scope ui-grid-cell-focus" tabindex="-1">33</div> </div> and it looks like: And I need to add / change value whihch is between divs (in this example...

Upload file - Protractor

javascript,selenium,testing,protractor,end-to-end
I fight with protractor because for some tests I need to UPLOAD file. My HTML looks like: <div class="panel-footer"> <ul class="list-unstyled"> <!-- ngRepeat: file in imagesToUpload --> </ul> <button class="btn btn-sm btn-success pull-right ng-binding ng-hide" ng-show="imagesToUpload.length" ng-click="uploadImages()">Nahrát na server</button> <button class="btn btn-sm btn-primary ng-binding" ng-file-select="onImageSelect($files)" data-multiple="true" style="overflow: hidden;">Vybrat soubory<input...

Forcing 'blur' on input field in angular e2e test

jquery,angularjs,blur,end-to-end
I have ng-blur functionality that I am trying to test in my angularjs e2e tests. Basically, when a field is blurred, data in another field will (depending on the circumstance) change as well. The following is my e2e test ([selector] and [selector2] are JQuery selectors for readability. The actual selectors...

Protractor testing a specific cell in ng-grid

angularjs,jasmine,protractor,angularjs-e2e,end-to-end
I need to locate and test a specific cell in an ng-grid table to ensure it's not showing 'NaN'. I have been able to locate cells in columns 1-7, but this cell is in column 14, which a user needs to scroll horizontally to see. When trying to locate cells...

How to change URL in protractor

javascript,testing,protractor,end-to-end
I'm wondering how do you change the current URL upon pressing some button or link. browser.waitForAngular(); expect(browser.driver.getCurrentUrl()).to.eventually.match(/document/).and.notify(callback); I know this code will get the url and match it with document, I would like to set the URL upon a click. e.g. I'm on Facebook and I want to go to...

Is it possible to get next sibling using cssContainingText in Protractor

angularjs,css-selectors,protractor,end-to-end
Is it possible to get the next sibling by using by.cssContainingText() Example: HTML code is like below: <div ng-repeat="SomeNgRepeat" class="ng-scope"> <div class="text-label" >SomeText</div> <div class="some-class">SomeValue</div> </div> Get element by using: element(by.cssContainingText('div.text-label','SomeText')) Now find the next sibling of the above element. I know of css=form input.username + input way of finding...

How to find and click a table element by text using Protractor?

javascript,angularjs,selenium,protractor,end-to-end
<tr id="item" ng-repeat="item in itemList> <td id="code" ng-repeat="column in columns">Some Text</td> </tr> I've seen some other similar questions but I couldn't solve it yet. Thats what I've tried so far: element.all(by.repeater('column in columns')).findElement(by.id('code')).getText('Some Text').click(); EDIT: <tr ng-repeat="item in items> <td>{{item.name}}</td> <td>{{item.description}}</td> </tr> Which results in: <tr> <td>Some Name</td> <td>Some...

How to get the value from selectbox?

javascript,selenium,testing,protractor,end-to-end
I am trying to verify that correct option is selected from selectbox using protractor. This is how I pick value from selectbox: element(by.id('form-mileage-unit')).click().then(function() { element(by.cssContainingText('option', browser.params.lengthUnit)).click(); });; So base on this I write code below: it('Verify paint color', function() { element(by.id('form-mileage-unit')).click().then(function() { element(by.cssContainingText('option', browser.params.lengthUnit).getAttribute("value")).toEqual(browser.params.lengthUnit); });; });...

Suites vs Specs Protractor

angularjs,testing,protractor,end-to-end,test-suite
I have recently picked up a project using Protractor. I am having troubles understand the difference between a suite and a specs. I am also having trouble with a suites when I am running a folder of test's after that folder is ran I run another folder of test and...

Protractor synchrozation - timeout

javascript,angularjs,testing,protractor,end-to-end
I am writing simple protractor test four our application: login page is without angularhs - working fine all other pages are with angularjs When i want to write angularhs test - i got this error (following this installation) : Timed out waiting for Protractor to synchronize with the page after...

What line is causing this Protractor error?

error-handling,webdriver,jasmine,protractor,end-to-end
Is there a way for Protractor to show in the console log what line the error occurred on? I just get this type of message: Message: Failed: Cannot call method 'click' of undefined Stack: Error: Failed: Cannot call method 'click' of undefined at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:104:16 at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15 at [object Object].webdriver.promise.ControlFlow.runInNewFrame_...

Protractor: get url of not angular page

javascript,angularjs,testing,protractor,end-to-end
Case I try to test: On Angular app page press button, that redirects you to some other site (not an Angular app). it('should go to 3d party service when i click "auth" button' , function() { browser.driver.sleep(3000); element(by.id('files-services-icon')).click(); element(by.id('box-vendor-menu-item')).click(); browser.driver.sleep(2000); expect( browser.driver.getLocationAbsUrl()).toContain('https://app.box.com/api/oauth2/authorize'); }); but I get: UnknownError: unknown error: angular...

AngularJs Protractor: Element in slide out menu not visible

javascript,angularjs,testing,protractor,end-to-end
I'm back with more Protractor Q&A. So, I am coming across an issue when trying for find an element that is inside a slide out menu. Snippet of html: <div class="ng-scope" ui-view="navmenu"> <nav class="menu slide-menu-left ng-scope"> <md-content class="md-default-theme" style="display: table" ng-click="slideMenuLeft()" tabindex="0"> <button class="md-button md-default-theme" ng-transclude="" style="width:50%;height:72px;border-right:1px solid #ddd;border-bottom:1px solid...

error while sending text to div field in Safari using protractor

selenium,selenium-webdriver,safari,protractor,end-to-end
I've got a text area div field: <div id="shortansweractivityId" class="shortanswerText ng-pristine ng-scope ng-isolate-scope ng-invalid ng-invalid-required ng-touched" ng-model="activity.answer" ng-if="isEditable" ng-focus="editing()" placeholder="Write here..." contenteditable="true" content-type="text"></div> I'm able to use sendKeys in chrome using: element(by.css('div#shortansweractivityId')).sendKeys('Test'); But when run the same in safari it errors out: UnknownError: undefined is not an object (evaluating 'b.value.length')...

Non-angular page opened after a click

javascript,angularjs,testing,protractor,end-to-end
I'm trying to implement the following test scenario: perform a click on a logo on the page assert there is a new browser window opened (tab in Chrome) and check the current URL The problem is that the page opened in a new browser window is a non-angular page while...

mouseover element not working using protractor

javascript,angularjs,testing,protractor,end-to-end
I have a directive that produces the following html structure: <div class="popover ng-isolate-scope" ng-mouseover="toggle(true)" ng-mouseleave="toggle(false)" popover="" label="hover time!" trigger-class="button" content-class="specialContentClass"> <span id="thing" class="popover-trigger button">hover time!</span> <div ng-transclude="" ng-show="show" class="popover-content ng-hide"> <div class="ng-scope">Popover content </div> </div> </div> The code works fine and the popover content is...

Protractor custom locator fails to locate the element

javascript,angularjs,selenium,protractor,end-to-end
I have added a custom data attribute to the elements i need to identify and interact using protractor. The attribute is data-test-id. I created a custom locator in the onPrepare callback in conf.js to detect the element. It is below: onPrepare: function () { by.addLocator('testId', function(value, parentElement) { parentElement =...

Load additional CONFIG file with values

javascript,selenium,testing,protractor,end-to-end
I am using lot's of values for my test like username and password. For this purpose I created a config file where I store just this data in JSON, it looks like: { "login": "test", "password": "pass", "number": "1234", } It works for me if I request it at start...

How can I use protractor to verify an URL?

javascript,testing,protractor,end-to-end
I would like to get the current URL using protractor, and then verify that this URL is the one that I need. I am using: istheSameURL(url) { return browser.getCurrentUrl() === 'http://localhost:9000/#/analysis/62/1'; } However, it is not working....

Element is not clickable at point - Protractor

javascript,testing,protractor,end-to-end
I'm getting an error that element I am trying to click on is not click able which I belieave is not true. My error looks: 1) Open VehiclePage and populate data Populate vehicle data Message: UnknownError: unknown error: Element is not clickable at point (1315, 371). Other element would receive...

Should I use ids to locate elements?

angularjs,selenium,protractor,end-to-end,e2e-testing
Started with Angular and Protractor. It just feels wrong to write some heavy css selectors which will break instant when you change something. Using ID's would make testing way easier. I'm not using any id attribute for styling yet. Are there any drawbacks using ids for testing I haven't considered?...

Edit ui-grid cell value using protractor

angularjs,testing,protractor,angular-ui-grid,end-to-end
I am using protractor to test angular 1.3.13 and ui-grid 3.0. All cells in grid are editable. In my tests I can get cell using following method: dataCell: function( gridId, fetchRow, fetchCol ) { var row = this.getGrid( gridId ).element(by.css('.ui-grid-render-container-body')).element( by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index').row( fetchRow ) );...

protractor iframe inside an iframe inside an iframe

testing,iframe,protractor,angularjs-e2e,end-to-end
I'm trying to get to controls inside a frame that is located inside a frame that is located inside another frame. The last (deepest) frame is used only for login - that I manage to do. The problem is that after the login I basically need to return to the...

Click on a element with same class that matches text and exit in Protractor

javascript,testing,selenium,protractor,end-to-end
I am able to find the text by using element.all(by.repeater()) in protractor and using each to check for matching text. Now the problem is exiting once the match is done and clicking on the matched element. I tried using .each(), but unable to exit iteration. Any Suggestions?...

How to identify this element in protractor?

javascript,testing,selenium,protractor,end-to-end
When I view some customer information, I see the customer information displayed at the bottom. I believe it comes from JSON call. How to identify this element? I tried className but not working. Thanks for your help. And tried this css as well. .override-info hide-mobile ng-scope. I need to assert...

Get attribute from table - Protractor

javascript,testing,protractor,end-to-end
Hey guys I have a table with multiple TR row, i need to be able to click on or any child <td> where VALUE is 91, In this example below there are just 2 values, but in a futurue there can be a 20 of them, and they can be...

E2E Protractor tests in firefox says 8 pending specs what does it mean?

javascript,selenium,jasmine,protractor,end-to-end
When I run my tests I get: 11 specs, 0 failures, 8 pending specs Finished in 56.861 seconds [launcher] 0 instance(s) of WebDriver still running [launcher] firefox #1 passed. What does this "8 pending specs" mean?...

Selector that will allow automatic Submit button click

javascript,testing,selenium,protractor,end-to-end
I have a 'Submit' button that becomes clickable after another action takes place. In this case, the user has to click the TOS checkbox and then the button becomes clickable. I cannot find a selector that will allow me to automate clicking the Submit button. When you click the Submit...

Protractor scrolling through executeScript not working

javascript,angularjs,google-chrome,protractor,end-to-end
I am testing my Ionic app. In one page, the button to be clicked is out of the bounds of the window. Hence the following code: element.all(by.css('.item.item-complex')).get(9).click(); throws the error: ElementNotVisibleError: element not visible Hence, I am trying to scroll down the page to make the button visible in page...

Asserting an element is focused

javascript,angularjs,testing,protractor,end-to-end
According to the How do I assert an element is focused? thread, you can check if an element is focused by switching to an activeElement() and assert this is the same element you've expected to have the focus: expect(page.element.getAttribute('id')).toEqual(browser.driver.switchTo().activeElement().getAttribute('id')); In my case, the currently focused element does not have an...

Are user acceptance test (UAT) and end-to-end (E2E) test the same thing?

testing,end-to-end,user-acceptance-testing
I've been trying to find the answer to this question online but I have not been able to find good enough to make me feel sure about the answer. I believe they are essentially the same but user acceptance test (UAT) requires a real user while end-to-end (E2E) test uses...

Jasmine toMatch url + uuid

testing,jasmine,protractor,end-to-end
After sending a click that causes the creation of a new resource, I'm using this to wait for the browser to get redirected to the newly created resource: browser.driver.wait(function() { return browser.driver.getCurrentUrl().then(function(url) { return url == 'https://dev.mysite.com/resource/'+/^[0-9a-fA-F]{24}$/ }); }); The problem is that I can't get the url==/myUrl to resolve...

undefined while returning a function value in protractor

javascript,testing,protractor,end-to-end
I have a function which returns a value: checkValue = function(Name){ var tempIndex=-1; var nameIndex=0; return selectElement.all(by.tagName('option')).each(function (element) { return element.getText().then(function(text){ tempIndex++; if(text.toString().indexOf(Name)!=-1){ nameIndex=tempIndex; return nameIndex; }else{ return nameIndex; }; }); }); This is called in another function: checkValue(Name).then(function(value){ logger.info("value ::"+value); }); When I call the above function the value...

How to count total number of option of drop-down in protractor

javascript,angularjs,testing,protractor,end-to-end
I am trying to verify number of options of drop-down but it is not working. I have used the following code: campaignManagementPage.statusDropDown().Count(); this.statusDropDown = function () { return element(by.model('campaign.lifeStage')); } HTML for drop down is following: <select class="form-control ng-pristine ng-valid ng-touched" data-ng- model="campaign.lifeStage"> <option value="design">Design</option> <option value="preview">Preview</option> <option value="live">Live</option> <option...

protractor click specific element in repeater by binding

javascript,testing,protractor,ng-repeat,end-to-end
I know that question was asked in the past in some different forms, but still didn't find the exact answer. I need to find an element inside a repeater and click it. the repeater is a list of apps and I need to find specific app with attribute 'displayName' that...

Are end-to-end tests better than unit tests, in situations where both are applicable?

unit-testing,integration-testing,end-to-end
Let me first define what I mean by unit and end-to-end tests. Let's say you have a program with a bunch of Java classes: A invokes B, which invokes C, and so on. A unit test is a test for A mocking out B, and separately a test for B...

How to simulate ctrl-click or shift-click with webdriver.io?

testing,end-to-end,webdriver-io
With webdriver.io I would like to simulate clicks with a modifier like shift or ctrl. The keys() method seems to do something like that but it's not clear to me how to release a modifier key again and it throws an error when I use 16 (key code for shift)...

Testing link style changes

css,testing,selenium,protractor,end-to-end
In one of our tests, we are testing the link (a element) style changes after a mouse over. By default, the link has a black font without decoration, but on mouse over the font changes to blue and the link text becomes underlined. Here is the relevant test: it("should change...

Protractor troubleshooting

angularjs,debugging,testing,protractor,end-to-end
In protractor 1.5.0, there was a new --troubleshoot flag introduced, which is not properly documented at the moment, but in the changelog it states: Improve error messages and add debug info when the configuration file cannot be parsed a webdriver session cannot be started more than one element is found...