angularjs-e2e

Mocking an angular service in Protractor

夙愿已清 提交于 2019-12-07 23:25:39
问题 I'm trying to use Protractor's addMockModule to insert mock data in my end-2-end test. My test is supposed to go to a web site, find a button by css-class and click it. The button click calls the function dostuff() in MyService, which fetches data from the backend. My code so far: describe('should display validation error', function () { it('should work', function () { browser.get('http://my.url'); browser.addMockModule('MyService', function () { // Fake Service Implementation returning a

Expect: does not get the actual value

两盒软妹~` 提交于 2019-12-07 22:37:14
问题 I faced with very strange problem. I had a set of tests which I run daily on Jenkins and without any noticeable changes some asserts(expects) started fail. THe strange thing here is that they fails ONLY if I execute tests from Jenkins on Browserstack. Locally everything just fine, locally on browserstack everything is fine, on saucelabs everything is fine. I have 3 it() blocks with similar expects: value1 = $('.someclass'); value2 = .. value3 = .. expect(value1.getText()).toContain('tratata')

Using Protractor: Switch to iframe using browser.switchTo().frame

二次信任 提交于 2019-12-07 21:48:38
问题 So I have already written the testing script which: 1) Logs into the application framework, then 2) Clicks menu to launch the app which I am testing ("MyAwesomeApp.html" for this post) And my main problem is: In navpanel-spec.js below, I want to target the https://server/apps/Default.aspx?r=1 URL, then click within the iframe where MyAwesomeApp is running. **** ERROR Trying to switch to the iframe this way, but it does NOT work: browser.switchTo().frame(element(by.id('1')).getWebElement());

Protractor - Page Object is not updating when the DOM elements are changed

一曲冷凌霜 提交于 2019-12-07 14:42:17
问题 I am testing a SPA built with angular.js and im using Page Objects pattern to write my tests. In the app we have a number of lists that will be updated. For example there is a list of attachments that will update when ever attachments are added/removed. To add an attachment we have a modal window and when we upload a file and click ok. The file uploads and the lists update. I have written 2 page objects, one for the upload modal window and the other one for the preview of the attachment list.

How to mock get(id) requests

99封情书 提交于 2019-12-07 09:33:58
问题 I am building an application prototype and try to mock the REST web-services. Here is my code: var mock = angular.module('mock', ['ngMockE2E']); mock.run(function($httpBackend){ users = [{id:1,name:'John'},{id:2,name:'Jack'}]; $httpBackend.whenGET('/users').respond(users); $httpBackend.whenGET(new RegExp('\\/users\\/[0-9]+')).respond(users[0]); } Everything is ok, my resource User.query() returns all users, and User.get({id:1}) and User.get({id:2}) returns the same user (John). Now to improve

'$' selector in Protractor

假装没事ソ 提交于 2019-12-07 05:40:59
问题 I have seen in many examples like this $('.selector') and I am also using this. So what this $ variable does. This is what I got from the protractor docs. Calls to $ may be chained to find elements within a parent. There is no example in docs which use $ alone. We are using $ to chain with element selector. Also $('.selector') itself is an element, when we does this element($('.selector')) , it is an error. So how to use this $ selector in protractor. Does it have all the features of JQuery $

(Protractor) Checking whether an input is disabled on click?

梦想的初衷 提交于 2019-12-06 18:32:59
问题 I have two input fields, Username and Password and a spinner button. When i click on this spinner button these two input fields get disabled and I am redirected to another page. I am writing an end-to-end testing to check whether these input fields are disabled. element(by.model('username')).sendKeys('rabi'); element(by.model('password')).sendKeys('rabi'); /* click on spin button */ spinBtn = element(by.className('call-to-action')); spinBtn.click(); /* check if input is disabled */ var

Download and use file with Protractor e2e test

时光怂恿深爱的人放手 提交于 2019-12-06 12:13:09
问题 How do I write a test that download a file, and post it in a form. it "should support download and upload a file", -> upload = element(By.id 'UploadInput'); upload.sendKeys 'C:\\path\\to\\file\\file.txt' Currently the upload works, but how do I download a file before and get it's path? 回答1: Solved it by adding the file to project and got the absolute path like this: it "should support download and upload a file", -> upload = element(By.id 'UploadInput'); upload.sendKeys path.resolve(__dirname

Expect: does not get the actual value

若如初见. 提交于 2019-12-06 11:53:14
I faced with very strange problem. I had a set of tests which I run daily on Jenkins and without any noticeable changes some asserts(expects) started fail. THe strange thing here is that they fails ONLY if I execute tests from Jenkins on Browserstack. Locally everything just fine, locally on browserstack everything is fine, on saucelabs everything is fine. I have 3 it() blocks with similar expects: value1 = $('.someclass'); value2 = .. value3 = .. expect(value1.getText()).toContain('tratata'); expect(value2.getText()).toContain('uhuhuhu'); expect(value3.getText()).toContain('ahahaha'); they

Protractor: Failed: protractor.getInstance is not a function

夙愿已清 提交于 2019-12-06 09:41:47
问题 I have installed protractor globally , and after locally. I am using this code: var protractor = require('protractor'); var ptor, driver; ptor.switchTo().frame(driver.findElement(protractor.By.tagName("iframe"))); driver.findElement(protractor.by.css(".cke_editable")).sendKeys("123"); And get this message: Failed: protractor.getInstance is not a function What am I do wrong? P.S. I havn't " lib/protractor.js ", only " bin/protractor ". 回答1: Wherever you are using var ptor = protractor