angularjs-e2e

Protractor - executing login scripts prior to launching my test specs

試著忘記壹切 提交于 2019-12-04 01:55:44
问题 The basic problem is here is that I was trying to login initially, launch my app, then run ALL specs. It turned out to NOT be a good approach. What I couldn't figure out is the following: Why navpanel-spec.js below was running first - before the login and launch js files. In other words, if I add a browser.pause() in navpanel-spec.js, it pauses immediately - PRIOR to even running my login-spec.js code. CONFUSING ! In my Protractor.config.js file I have a few specs : specs: [ 'spec/login.js',

Test login with protractor on a non angular page

我只是一个虾纸丫 提交于 2019-12-03 12:02:10
I am trying to use protractor for e2e testing but first I need to login on a non-angular page. I try to directly use the webDriver as indicated here but it fails. My e2e test: describe('angularjs homepage', function() { it('should prompt the login page', function() { browser.get('/'); expect(browser.driver.find(By.id('user_password'))); }); }); My logs: Running "protractor:all" (protractor) task Using the selenium server at http://localhost:4444/wd/hub F Failures: 1) angularjs homepage should prompt the login page Message: TypeError: Object [object Object] has no method 'find' Do you know a

Setting cookies before browser.get

落爺英雄遲暮 提交于 2019-12-03 11:40:55
问题 Our (PHP) application requires certain cookies to be set in order to load an Angular.js client app. If the cookies are not set an exception is thrown and error page is shown. This means in order to run E2E tests we need to set the cookies, but the following fails because Protractor is trying to find Angular right after the browser.get call (it's not there because the exception was thrown). browser.get('http://' + domain + '/'); browser.manage().addCookie('foo', 'boo', '/', domain); I tried to

How to getText from all rows & columns in an infinite scrolling ng-grid using protractor?

ε祈祈猫儿з 提交于 2019-12-03 09:39:30
I am trying to write a function which returns the complete grid content in an array. Our ng-grid has infinite scrolling through the rows and also have scrolling through the columns. I have found an answer for scrolling here Protractor: Scrolling a table and testing for infinite scroll But I am looking to scroll through the grid fully and get the data, So that I can validate the data when I apply filters to the grid. Any help on this is highly appreciated, thanks Sample HTML Code for the rows <div class="ag-body" style="padding-top: 25px; padding-bottom: 30px;"> <div class="ag-pinned-left-cols

Protractor instance vs browser

白昼怎懂夜的黑 提交于 2019-12-03 04:30:53
I have tried to looked up for similar QA's but i couldn't find one to satisfy me. So basically i saw that in some examples it's used ptor = protractor.getInstance(); ptor.get(url); And in some other examples it's used. browser.get(url); So th question is: What's the difference using protractor instance and browser for getting specific url? Also if my assumption in the P.S. is right, which is better practice: to use only protractor, or to mix them? P.S. Also i saw same difference in usage with the debugger. I know that protractor is a wrapper over web driver and i assume that protractor

Protractor Page Objects Inheritance

末鹿安然 提交于 2019-12-03 03:50:57
问题 Given i'm building my angularjs protractor e2e tesing suite leveraging the page objects pattern. And i separate page object code in different files as much as reasonable. What would be a good approach to enable page objects inheritance? javascript classic inheritance? Object.create() based inheritance? Other? Should i keep expectations within the page object? Or favor Martin Fowler optinion by moving them to an assertion library? in which case how exactly would that look like in this

Protractor how to run login test script first

我的梦境 提交于 2019-12-03 03:18:11
I am trying to test an Angular Single Page application with protractor. I need to run the login script first. Only then I can move to other routes since there is a check for token in localStorage on route change. Is this testing approach correct?. In that case I need to run the login script first. Does protractor allows to control the spec file order. Or should I run the each script independently by hardcoding the token in localStorage (Should I do login api call independently before each test). My login script contains the following it('Login with wrong email', function() { }) it('Login with

Javascript.confirm() and Angularjs Karma e2e test

两盒软妹~` 提交于 2019-12-03 02:25:27
I have an Angularjs application that uses simple javascript confirm before executing some actions. Controller: function TokenController($scope) { $scope.token = 'sampleToken'; $scope.newToken = function() { if (confirm("Are you sure you want to change the token?") == true) { $scope.token = 'modifiedToken'; } }; } View: <div id="tokenDiv"> Token:{{token}} <button ng-click="newToken()">New Token</button> </div> Now I want to have an end to end test to check the token is being replaced correctly in the view. How can I intercept the javascript.confirm() call so it doesn't stop the execution of the

Adding headers in browser.get() requests in protractor

倖福魔咒の 提交于 2019-12-02 00:30:47
问题 i want to add cookies in headers for automatic authorization in test with protractor, but there is no native way to do this, how i understand... How can i add custom headers to browser.get() request ? 回答1: Selenium (WebDriver) does not support this. One way of solving this is by using a intermediate proxy and manipulating the headers along the line. Keep in mind that this solution works perfectly fine for HTTP, but will will require some additional workarounds if you are using HTTPS (and in

How to find element by two attributes

試著忘記壹切 提交于 2019-12-01 12:56:06
I have radio buttons like, how can I get the second one clicked finding first by ng-model then ng-value : <input type="radio" ng-model="vm.ist.educationVsInternship" ng-value=false /> <input type="radio" ng-model="vm.ist.educationVsInternship" ng-value=true /> I tried something like element(by.model('vm.ist.educationVsInternship')).all(by.css('[ng-value=true]')).click(); says and does not click any of them more than one element found for locator by.model("vm.ist.educationVsInternship") - the first result will be used and this: element(by.model('vm.ist.educationVsInternship')).element(by.css('