Menu
  • HOME
  • TAGS

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

unit-testing,integration-testing,end-to-end

I would consider future changes and complexity to decide which one to go: If A's behaviour is likely fixed (says it's an API), while B & C are likely to be replaced/changed in the near future (says they are internal components that use an external library that is near its...

Non-angular page opened after a click

javascript,angularjs,testing,protractor,end-to-end

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...

protractor iframe inside an iframe inside an iframe

testing,iframe,protractor,angularjs-e2e,end-to-end

The problem is that after the login I basically need to return to the upper frame and click a button. From what I see in your code, you are switching to the default content, but, as you said, the button is inside the upper iframe, switch to it: browser.driver.switchTo().defaultContent();...

Protractor: get url of not angular page

javascript,angularjs,testing,protractor,end-to-end

You need to do 2 things Set browser.ignoreSynchronization = true; before trying to read the URL of the 3rd party page, so the browser doesn't wait for (and so require) Angular promises to resolve in the page (and set it to false afterwards); Use browser.getCurrentUrl() as opposed to browser.getLocationAbsUrl(), as...

Protractor - Get text from table

javascript,testing,selenium-webdriver,protractor,end-to-end

There is a relevant by.linkText() locator that should fit the use case: var link = element(by.linkText(global.caseNumber)); If it still doesn't find the desired element, try adding a wait: var EC = protractor.ExpectedConditions; browser.wait(EC.presenceOf(link), 5000); ...

Testing templates in Protractor?

javascript,angularjs,testing,protractor,end-to-end

First of all, for writing cleaner tests and having a better understanding of what your target site consists of, apply the Page Object pattern and split the parts of your web pages into different page objects. For instance, footer, header can and should be separate page objects that would be...

What line is causing this Protractor error?

error-handling,webdriver,jasmine,protractor,end-to-end

Here is a related issue at jasminewd project that protractor uses under-the-hood: Stack traces for Jasmine2 don't include asynchronous events The issue is now fixed, with jasmine upgrade to >=2.3.1. What you should do is to upgrade protractor to >=2.1.0. Old answer: As a workaround, get back to jasmine 1.x:...

Slider testing using protractor

angularjs,testing,protractor,end-to-end,e2e-testing

You should pass an element you found to dragAndDrop(): var slider = element(by.id('slider')); browser.actions().dragAndDrop( slider, {x:100, y:0} ).perform(); See other examples here: Drag and drop using protractor in dthmlx component How to simulate a drag and drop action in protractor? ...

mouseover element not working using protractor

javascript,angularjs,testing,protractor,end-to-end

One possible problem is that you need to make it wait for angular to load: it('should display the popover-content on mouseover', function() { browser.get('http://localhost:9000/'); browser.waitForAngular(); browser.actions().mouseMove(element(by.css('.popover'))).perform(); expect(element(by.css('.popover-content')).isDisplayed()).toBeTruthy(); }); I've also removed the find() call (not sure if you really need it here) and fixed the parenthesis closing order in the...

Cloning element finders

javascript,testing,selenium,protractor,end-to-end

Clone was introduced here: https://github.com/angular/protractor/issues/1303. And honestly now I think about it, it was a mistake to introduce it, as it offers no practical values. Originally, there was fear that subsequent chains of elementFinders would affect previous ones: var outerElement = element(by.abc...).all(by.def...).first().element(by.ghi...); var outerText = outerElement.getText(); var innerElement = innerElement.element(by.xyz...);...

Cleanup for running spec files in series in Protractor

protractor,end-to-end

I used a different approach and it worked for me. Inside my first spec I am adding Logout testcase which logouts from the app and on reaching the log in page, just clear the cookie before login again using following: browser.driver.manage().deleteAllCookies(); ...

Get attribute from table - Protractor

javascript,testing,protractor,end-to-end

xpath is your friend when you need exact value matching. This should do the trick: element.all(by.xpath('.//td[.="91" and @class="ultranarrow ng-binding"]')).click(); ...

Add two parameters in function into “then” protractor

javascript,angularjs,unit-testing,protractor,end-to-end

This is a classic closure problem that is described in detail in: Using protractor with loops In your case, just let expect() resolve the promise: var categories = ['1','2','3']; for (var i = 0; i < categories.length; i++) { var link = '/' + categories[i]; browser.get(link); browser.sleep(2000); expect(browser.driver.getCurrentUrl()).toMatch(link); } ...

Edit ui-grid cell value using protractor

angularjs,testing,protractor,angular-ui-grid,end-to-end

Solved it. You need to focus cell and access input element: cell.click(); cell.element(by.css(".ui-grid-cell-focus input")).sendKeys("newCellValue"); EDIT: Has some issues on older browser versions, better to use: cell.click(); cell.element(by.css("input")).sendKeys("newCellValue"); EDIT: Another issue is with Firefox where cell.click() is not working properly. Workaround/hack: http://stackoverflow.com/a/23370177...

Is it possible to add a plugin to chromedriver under a protractor test?

javascript,angularjs,protractor,selenium-chromedriver,end-to-end

You need to configure extensions list inside chromeOptions: capabilities { 'browserName': 'chrome', 'chromeOptions': { 'extensions': ['base64 encoded extension'] } } Note that it in extensions, it is important to provide a list of base-64 encoded packed Chrome extension. To get a base64 encoded extension, you need to read the .ctx...

How to get the value from selectbox?

javascript,selenium,testing,protractor,end-to-end

You are closing the parenthesis in the wrong place and there is no expect(). Replace: element(by.cssContainingText('option', browser.params.lengthUnit).getAttribute("value")).toEqual(browser.params.lengthUnit); with: var option = element(by.cssContainingText('option', browser.params.lengthUnit)); expect(option.getAttribute("value")).toEqual(browser.params.lengthUnit); If you are dealing with select->option constructions a lot, consider using an abstraction over it that would make your tests cleaner and more readable, see: Select...

Asserting an element is focused

javascript,angularjs,testing,protractor,end-to-end

In my answer I'm going to assume activeElem and pageElem are both protractor element finders, and are pointing to the same web element. First to answer your question about why expect(activeElem).toEqual(pageElem); Gets into an infinite loop, it's because protractor patched jasmine's expect to resolve the promise before asserting, so that...

Testing link style changes

css,testing,selenium,protractor,end-to-end

This asynchrony in the CSS update seems like something that protractor/webdriver should be able to wait for. Is your app doing anything unusual to implement the CSS update on hover? Is it specifying an animation or update delay somehow? That said, I think there can be times when protractor cannot...

protractor click specific element in repeater by binding

javascript,testing,protractor,ng-repeat,end-to-end

There are multiple ways to locate the desired element, though I would chain element.all() and element() and use by.xpath() locator strategy: var a = element.all(by.repeater("app in userApps")).element(by.xpath(".//a[strong = 'appName1']")); a.click(); Or, using filter(): element.all(by.repeater("app in userApps")).filter(function (elm) { return elm.evaluate("app.displayName").then(function (displayName) { return displayName === "appName1"; }); }).then(function (elms) {...

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

testing,end-to-end,webdriver-io

Edit: If you want to select different elements using ctrl key: client.elements(<css selector for your list of elements>, function(err, res) { client .moveTo(res.value[<index of element you want to select>].ELEMENT, 0, 0) .keys('Ctrl') #every action after this within the scope of `client.elements` will have the `ctrl` key depressed .buttonPress('left') .moveTo(res.value[<index of...

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

testing,end-to-end,user-acceptance-testing

User Acceptance Test is a phase in a typical software development process. From the other side, End-To-End test is one of the approaches to testing the complex applications which involves all layers of the application to interact with each other during test execution. It means that you can execute End-to-End...

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

javascript,testing,selenium,protractor,end-to-end

In this case, each() is not a good choice. It really sounds like filtering, example: element.all(by.repeater("test in tests")).filter(function (elm) { return elm.getText().then(function (text) { return text === "Desired text"; }); }).then(function(filteredElements) { filteredElements[0].click(); }); ...

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

javascript,selenium,jasmine,protractor,end-to-end

This is coming from your test framework (I assume jasmine): Pending specs do not run, but their names will show up in the results as pending. Any spec declared with xit is marked as pending. Any spec declared without a function body will also be marked pending in results. And...

Protractor - Storing a value for later use

javascript,selenium,protractor,end-to-end

You can use onPrepare in protractor's config file to execute some code once before all the tests (example). Keep in mind that you'll have to load a page of your application before being able to use getCookie....

Protractor: Testing multiple user logins for conflicts during updating

angularjs,testing,protractor,end-to-end

This should help you: https://github.com/angular/protractor/blob/master/docs/browser-setup.md#using-multiple-browsers-in-the-same-test and here's an example: https://github.com/angular/protractor/blob/master/spec/interaction/interaction_spec.js...

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

javascript,angularjs,testing,protractor,end-to-end

Define a separate field in your page object: this.statusDropDownItems = function () { return element.all('select.form-control option'); } or relying on the model and chaining element and element.all: this.statusDropDownItems = function () { return element(by.model('campaign.lifeStage')).element.all('option'); } Then, in your test spec you can use expect to assert the count: expect(page.statusDropDownItems.count()).toEqual(4); where...

Protractor synchrozation - timeout

javascript,angularjs,testing,protractor,end-to-end

You need to let protractor know that the login page is non-angular and it doesn't need to wait for angular to "settle down". Set the ignoreSynchronization to true before login and set it back to false after: describe('Login #1', function() { afterEach(function () { browser.ignoreSynchronization = false; }); it('should pass...

Testing tab navigation order

javascript,testing,selenium,protractor,end-to-end

I think the PageObject should define a tab order list, since that is really a direct property of the page, and should be expressible as simple data. An array of items seems like a sufficient representation, so something like: this.tabOrder = [ this.registrationCode, this.rememberRegistrationCode, this.requestCode, this.cancelButton ]; Then you need...

How to change URL in protractor

javascript,testing,protractor,end-to-end

Why don't actually let the browser navigate to the new URL on click, get it via browser.getCurrentUrl(), modify it and navigate to the modified URL, e.g. button.click(); var url = browser.getCurrentUrl(); url = url + "?a=b"; browser.get(url); ...

protractor-html-screenshot-reporter not showing all the tests executed in the reporter file

javascript,angularjs,testing,protractor,end-to-end

I was able to reproduce it - this is always the latest it block that is missing in the final HTML report. This should be reported to the protractor-html-screenshot-reporter bug tracker. As a current workaround, downgrade to protractor 1.4.0 (tested, worked for me). Or, add an empty it() block to...

How to determine if is disabled

html,angularjs,testing,protractor,end-to-end

You need to get the attribute directly like this: expect(myelement.getAttribute('disabled')).toBeTruthy(); I use this in my Protractor testing daily without issue....

Custom message on wait timeout error

testing,selenium,jasmine,protractor,end-to-end

I believe browser.wait() takes 3 parameters: a condition, an optional timeout, and an optional description message. (I'm pretty sure this is the doc: http://angular.github.io/protractor/#/api?view=webdriver.WebDriver.prototype.wait, but I'm having a hard time verifying that the WebDriver shows up as browser in protractor). So you should be able to do: var EC =...

How to setup endless testing with Protractor with SauceLabs?

angularjs,testing,protractor,saucelabs,end-to-end

This is something you should not solve on the protractor level. Use jenkins or other continuous integration servers, or simply schedule it in cron....

Protractor + angular error - Element is not clickable at point

javascript,angularjs,testing,protractor,end-to-end

It turned out that the test before the one causing problems was opening the modal and leaving it open, and then when this test tried to open a new modal, couldn't find the button to do so because the modal was already open. I didn't realize that the very first...

when i am try to get text of a binding element, it gives the total text of the div element

angularjs,google-chrome,selenium-webdriver,protractor,end-to-end

element() call here refers to an ElementFinder which represents a single element. In other words, you are getting an element containing the binding (div), not the value of the binding itself. You should assert the complete element text in this case: expect(element(by.exactBinding('input.visaValidFrom')).getText()).toBe('2015-01-03 - 2015-12-01'); Or, you can manually split the...

Protractor testing a specific cell in ng-grid

angularjs,jasmine,protractor,angularjs-e2e,end-to-end

Scrolling into view should help here: var elm = rows[6].element(by.className('colt14')); browser.executeScript("arguments[0].scrollIntoView(true);", elm.getWebElement()); cell = elm.getText().then(function (data) { return data.replace(/ /g,''); }); ...

How to cange the date and time of my computer device, using protractor

angularjs,google-chrome,selenium-webdriver,protractor,end-to-end

Think about it differently. Mock the HTTP response that your app sends containing announcements and set the desired date using protractor-http-mock library. In other words, let the frontend think there is an expired announcement. Alternative options would include mocking the time with the help of Sinon.js or TimeShift.js, but, personally,...

Element is not clickable at point - Protractor

javascript,testing,protractor,end-to-end

The combo-box from the error message is still open when you are trying to click on the vehicle-condition element - most probably due to its closing/fade-out animation. You can try to disable animations for your tests globally, locally or wait for the overlaying element to disappear: var EC = protractor.ExpectedConditions;...

Object # has no method 'getInstance' when trying to run Protractor tests

javascript,angularjs,testing,protractor,end-to-end

You don't need to call protractor.getInstance() anymore, use globally-available browser object: this.title = browser.getTitle(); And, yes, this was a breaking change in 1.5.0, see: Breaking Changes ...

Insert value to div

javascript,angularjs,testing,protractor,end-to-end

You need to set an innerHTML using executeScript(): var elm = element(by.xpath('(/html/body/div[2]/div/div/div[2]/form/fieldset[2]/div[2]/div/div/div[2]/div[2]/div/div/div/div[3]/div)')); browser.executeScript("arguments[0].innerHTML = '11';", elm.getWebElement()); Also, think about changing the xpath you are using - this one (an absolute one starting from the html root element) is very fragile....

How to end to end test a web application?

testing,end-to-end

All tests need data to test against, even black box testing. Typically you will have a setup function that populates your database with data before the test runs. You will likely have a teardown step as well, which might restore the database to a pre-test state. This in no way...

How to identify this element in protractor?

javascript,testing,selenium,protractor,end-to-end

You can rely on class names: expect(element .all(by.css("div.override-info p.override-info-dtl")) .first().getText() ).toEqual("John Grish"); ...

How can I use protractor to verify an URL?

javascript,testing,protractor,end-to-end

browser.getCurrentUrl() doesn't work with IE 10 if I recall. If you want to test against IE, you'll have to write some jquery that does that. I combined both the browser.getCurrentUrl method and the jquery into a function, did an if-check on the browser, and then put that in a common...

Should I use ids to locate elements?

angularjs,selenium,protractor,end-to-end,e2e-testing

The general rule is to use IDs whenever possible assuming they are unique across the DOM and not dynamically generated. Quoting Jim Holmes: Whenever possible, use ID attributes. If the page is valid HTML, then IDs are unique on the page. They're extraordinarily fast for resolution in every browser, and...

Using angular functions ($q) in protractor

angularjs,testing,protractor,end-to-end

From the looks of your code containers is a list of elementFinders? (i.e. var containers = [element(by.x), element(by.y), element(by.z)]): Using q: (you need to add q as dependency in package.json first) var q = require('q'); var collectEntries = function(containers) { var entries = {}; containers.each(function (container) { var deferred =...

protractor: test for focus of field

angularjs,testing,protractor,end-to-end

You need to wait for angular before making any assertions: beforeEach(function() { browser.get(loginURL); browser.waitForAngular(); }); Aside from that, this might be connected to the autofocus attribute, it has/had issues in Firefox, see: Autofocus Attribute of HTML5 does not work only in FireFox when <Form><input> are loaded via Ajax. WHY? Why...

Suites vs Specs Protractor

angularjs,testing,protractor,end-to-end,test-suite

Suites are incredibly useful for organizing your tests. The question actually goes down to differences between a suite and a test case in general. Quote from the wikipedia "Test suite" definition: a collection of test cases that are intended to be used to test a software program to show that...

Protractor: How can I get the next tag

angularjs,testing,jasmine,protractor,end-to-end

You can use by.xpath() and ask for the following ul sibling: element(by.id('second-input')).element(by.xpath('following-sibling::ul')); Or, in one go: element(by.xpath('//input[@id="second-input"]/following-sibling::ul')); Another option would be to use by.css() with an adjacent sibling selector: element(by.css('#second-input + ul')); ...

Protractor: Checking data is sorted by date

angularjs,testing,protractor,end-to-end

Get the list of all birth dates using map(), convert the list of strings to the list of dates and compare with a sorted version of the same array: element.all(by.id('birth-date')).map(function (elm) { return elm.getText().then(function (text) { return new Date(text); }); }).then(function (birthDates) { // get a copy of the array...

Protractor get element by model in repeater array

angularjs,testing,protractor,angularjs-e2e,end-to-end

The value passed into by.model() should be as is on the page: var activePost = posts[0].element(by.model('post.active')); Note that activePost variable would refer to an element, hence even if it's value would be false (unchecked checkbox), the expect(activePost).toEqual(true); expectation would be met. You need to assert the checkbox's value instead using...

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

angularjs,testing,protractor,angularjs-e2e,end-to-end

As for unhecked inputs, you can check that there is no checked atrribute set: expect(element.all(by.xpath('//input[@type="checkbox" and not(@checked)]')).isSelected()).toEqual([false, false, false, false, false, false, false, false, false, false]); If it is always 3 checked and 7 unchecked, you can assert the count also: expect(element.all(by.xpath('//input[@type="checkbox" and not(@checked)]')).count()).toEqual(7); expect(element.all(by.xpath('//input[@type="checkbox" and @checked="checked"]')).count()).toEqual(3); ...

Selector that will allow automatic Submit button click

javascript,testing,selenium,protractor,end-to-end

Click the TOS checkbox to enable the button, locate it by text and click: var submitButton = element(by.xpath("//button[contains(., 'Submit')]")); submitButton.click(); If, for some reason, you cannot enable the button and, hence, click it using element.click(), you can simulate the click by executing javascript: browser.executeScript("arguments[0].click();", submitButton.getWebElement()); ...

Re-run protractor timeout or failed tests

angularjs,testing,protractor,end-to-end

As far as I understand, currently it is not possible, but there is an open feature request: Feature to execute failed tests only ...

Protractor clicking on the link, but element is not visible?

angularjs,selenium-webdriver,protractor,end-to-end

From your comment, I suggest you to use the onPrepare option in your Protractor config to maximize the browser window before your specs start running: onPrepare: function() { browser.driver.manage().window().maximize(); } ...

How to run single e2e test with grunt and protractor

javascript,angularjs,gruntjs,protractor,end-to-end

You just have to pass the specs option to the protractor CLI. The specs option expects a comma-separated list of JS files to run. You'll need to edit your Gruntfile.js to pass this option to protractor....

Protractor: cleanup after test suite is finished

javascript,selenium,testing,protractor,end-to-end

From what I understand, there is no place in protractor to provide "before test suite" or "after test suite" logic (correct me if I'm wrong about it). The idea is to use afterEach(), try switching to the alert, dismiss() it if exists (or accept() depending on what you need), do...

Check POST request payload data with Protractor

angularjs,testing,jasmine,protractor,end-to-end

Following @Andres D's comment: yes, there is a misconception here. protractor is a tool that helps you mimic real-user interactions with a page by automating a real browser. It stays on the high-level, sees what a normal user can see - click buttons, fills out inputs etc. In other words,...

How to select an element in protractor having multiple classes?

angularjs,testing,jasmine,protractor,end-to-end

Try replace class2 to .class2.

Protractor custom locator fails to locate the element

javascript,angularjs,selenium,protractor,end-to-end

When you are getting the attribute, you should ask for data-test-id instead of [data-test-id]. Looks like a copy-paste error. Replace: return (node.getAttribute('[data-test-id]') === value); with: return (node.getAttribute('data-test-id') === value); ...

Protractor browser.wait doesn't actually wait

javascript,angularjs,testing,protractor,end-to-end

It is all about promises (actually every protractor question is about promises). browser.wait() is not a blocking call, it schedules a command to wait for a condition: Schedules a command to wait for a condition to hold, as defined by some user supplied function. If any errors occur while evaluating...

Protractor troubleshooting

angularjs,debugging,testing,protractor,end-to-end

Currently --troubleshoot does two things: It parses the config and provides suggestions on it It prints out all the relevant environment variables (OS, protractor version, framework, capabilities, etc) so that when they report the problems others like me can look at this information to identify if the issue is related...

Jasmine toMatch url + uuid

testing,jasmine,protractor,end-to-end

You need to use match(): browser.driver.wait(function() { return browser.driver.getCurrentUrl().then(function(url) { var re = /resource\/[0-9a-fA-F]{24}$/; return url.match(re); }); }); Note that slash inside the url has to be escaped with a backslash....

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

If ng-app is not defined on html or body, you need to let protractor know about it by setting rootElement configuration setting: exports.config = { seleniumAddress: env.seleniumAddress, baseUrl: env.baseUrl, ... // Selector for the element housing the angular app. rootElement: 'div#nested-ng-app' }; This would make playing around with switching syncing...

Get all element attributes using protractor

javascript,testing,selenium,protractor,end-to-end

You can expand javascript's Element type and add getAttributes() function: Element.prototype.getAttributes = function() { return (function (node) { var attrs = {}; for (var i=0;i<node.length;i++) { attrs[node.item(i).name] = node.item(i).value; } return attrs; })(this.attributes); }; demo then you can test integrity of attributes using the same method you use for one...

undefined while returning a function value in protractor

javascript,testing,protractor,end-to-end

You are getting undefined since this is what each() returns (returns nothing), implementation: ElementArrayFinder.prototype.each = function(fn) { return this.map(fn).then(function() { return null; }); }; Let's approach it differently, using map(): return selectElement.all(by.tagName('option')).map(function (option, index) { return { 'text': option.getText(), 'index': index }; }).then(function (options) { for (var i = 0;...

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

javascript,angularjs,selenium,protractor,end-to-end

You need to filter() the desired element: var columns = element.all(by.repeater('column in columns')); columns.filter(function (elm) { return elm.getText().then(function (text) { return text == 'Some Text'; }); }).first().click(); ...

protractor - switch to facebook login screen when testing Oauth2

testing,oauth-2.0,protractor,end-to-end,e2e-testing

Instead of a name of the window, you need to provide a handle: browser.getAllWindowHandles().then(function (handles) { // switch to the popup browser.switchTo().window(handles[1]); // do stuff with the popup // ... // go back to the main window browser.switchTo().window(handles[0]); }); ...

Protractor scrolling through executeScript not working

javascript,angularjs,google-chrome,protractor,end-to-end

When I encounter issues like this, I scroll into view: var elm = element.all(by.css('.item.item-complex')).get(9); browser.executeScript("arguments[0].scrollIntoView();", elm.getWebElement()); elm.click(); ...

Forcing 'blur' on input field in angular e2e test

jquery,angularjs,blur,end-to-end

Thanks to Nobita for letting me know how to properly close out a question. Most of this is repeated from my first edit in the question. After much debugging I found that the blur was being triggered correctly (method 3 above, which caused the error, never worked, but the other...

Is it possible to get next sibling using cssContainingText in Protractor

angularjs,css-selectors,protractor,end-to-end

What if you would get it in one go using by.xpath(): element(by.xpath('//div[@class="text-label" and . = "SomeText"]/following-sibling::div')) Or, you can combine it with cssContainingText(): element(by.cssContainingText('div.text-label','SomeText')).element(by.xpath('following-sibling::div')) ...

Load additional CONFIG file with values

javascript,selenium,testing,protractor,end-to-end

To follow the "DRY" principle, use your protractor config and globally available browser object: in your protractor config, "import" your configuration file and set it as a params value: var config = require("./config.js"); exports.config = { // ... params: config, // ... } in your tests, simply use browser.params, e.g.:...

Protractor: testing date text with various formats

angularjs,testing,protractor,end-to-end

I think you need to compare Date objects, not strings: element(by.id('date')).getText().then(function (value) { var dateValue = new Date(value); var expectedDateValue = new Date(dateValue.getFullYear(), 9, 30, 10, 45, 0); expect(dateValue).toBe(expectedDateValue); }); If you want to additionally check the format, you can dive into the wonderful world of regular expressions, or just...

Protractor - compare numbers

javascript,angularjs,protractor,subtraction,end-to-end

Both firstCount and secondCount are promises that are needed to be resolved: element.all(by.repeater('app in userApps')).count().then(function (first) { element.all(by.repeater('app in userApps')).count().then(function(second) { expect(first - second).toEqual(1); }) }); ...

AngularJs Protractor: Element in slide out menu not visible

javascript,angularjs,testing,protractor,end-to-end

You need to open up the menu before locating and clicking the submenu: element(by.css('nav.menu > md-content')).click(); element(by.css('nav.menu > md-content > button[ng-click="logoff()"]')).click(); You may also need to use a elementToBeClickable expected condition to wait for the submenu to become clickable (needs protractor 1.7 or above): var EC = protractor.ExpectedConditions; var logoff...

Upload file - Protractor

javascript,selenium,testing,protractor,end-to-end

The common and the most realistic way to upload the file via protractor/selenium is to send keys to the file input and avoid opening the upload file dialog which you cannot control: var uploadInput = element(by.css("input[type=file]")); uploadInput.sendKeys("path/to/file"); ...

Click on element - Protractor

testing,protractor,end-to-end

After some research I found out iframe is loading on TOP of page, and I was trying to click to IFRAME that's why I wasn't able to find element. Thanks @alecxe for lead me in right way with DEV TOOls. If you wonder how to click to iFrame, it is...

How can I do a Ctrl+Click on protractor?

javascript,angularjs,node.js,protractor,end-to-end

You need to chain mouseMove(), keyDown() and click(): var elm = element(by.id('my_id')); browser.actions() .mouseMove(elm) .keyDown(protractor.Key.CTRL) // COMMAND for Mac .click() .perform(); Tested it on Chrome by clicking on a link - opens up a link in a new tab. Note that, starting with protractor 1.5, there is a global browser...

Protractor gives “Unable to start a WebDriver session” error

javascript,google-chrome,testing,protractor,end-to-end

According to the relevant github issue, the problem is that chromedriver cannot find chrome browser executeable - on different operating systems it searches for it in different places. You need to either have chrome installed where chromedriver expects it to be, or specify the path to the chrome executeable in...

error while sending text to div field in Safari using protractor

selenium,selenium-webdriver,safari,protractor,end-to-end

Made it work in safari using jquery in browser.executeScript().

How to stop protractor from running further testcases on failure?

javascript,testing,jasmine,protractor,end-to-end

In case of jasmine testing framework, you are not the first asking about it. There are relevant open discussions/issues on exiting after a first failure, --fail-fast option: Bail on first failure --fail-fast option? Please add --fail-fast support Long story short, this is an open issue and some day jasmine would...

Protractor click element by repeater

testing,protractor,end-to-end

Instead, try calling first() on the ElementArrayFinder: var rows = element.all(by.repeater("car in axCarSearch.found")); rows.first().element(by.tagName("a")).click(); ...

protractor: onPrepare for different test suites

angularjs,testing,protractor,end-to-end

As far as I understand, you need a place for suite-specific preparations. This is what jasmine can help you with. For jasmine 2.1 and above, there are built-in beforeAll and afterAll notations: The beforeAll function is called only once before all the specs in describe are run, and the afterAll...

“More than one element found for locator” warning

angularjs,testing,warnings,protractor,end-to-end

Try this instead: element.all(by.css("ul.nav button")).first() Basically, this tells Protractor that you already know there's more than one element, and you just want the first one (like you said in your question)....

Protractor - count elements in repeater and print it

angularjs,testing,angularjs-ng-repeat,protractor,end-to-end

If I'm understanding your problem correctly, you actually want to print the count and not dumping the entire content right? element.all(by.repeater('app in userApps')).count().then(function(count) { console.log(count); }); ...