protractor

Protractor: Get text of an alert?

半城伤御伤魂 提交于 2019-12-23 09:53:40
问题 I'm testing my Angular app with Protractor. I've looked through the docs and can't find any way to get the text of an alert. It's not an element in the DOM per se (at least, not that I can figure out; when there's an alert up, Chrome's inspector won't allow you to inspect it). How would I test that an alert has the correct message? Or even, that one is present? Edit Here is my code. HTML: <button id='alertButton' data-ng-click='ngAlert()'>Button</button> JS: $scope.ngAlert = function(){

How to get a row and its column from a table with Protractor

北慕城南 提交于 2019-12-23 09:09:21
问题 <div class="k-grid-content"> <table> <tbody> <tr> <td>row1Col1</td> <td>row1Col2</td> <td>row1Col3</td> </tr> <tr> <td>row2Col1</td> <td>row3Col2</td> <td>row4Col3</td> </tr> <tr> <td>row3Col1</td> <td>row3Col2</td> <td>row3Col3</td> </tr> </tbody> </table> </div> var grid = element.all(by.css('.k-grid-content tr')); //this will return row1,row2,row3 but I am unable to use code below to get each row and its column. grid.each.each(function(row){ var rowElems = row.findElements(by.tagName('td')

Assert an array reduces to true

无人久伴 提交于 2019-12-23 08:56:19
问题 In one of the tests, we need to assert that one of the 3 elements is present. Currently we are doing it using the protractor.promise.all() and Array.reduce(): var title = element(by.id("title")), summary = element(by.id("summary")), description = element(by.id("description")); protractor.promise.all([ title.isPresent(), summary.isPresent(), description.isPresent() ]).then(function (arrExists) { expect(arrExists.reduce(function(a,b) { return a || b; })).toBe(true); }); Is there a better way to

Element is not clickable at point - Protractor

风流意气都作罢 提交于 2019-12-23 07:49:27
问题 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 the click: <div class="form-con rol combo-options ng-scope ng-animate ng-leave ng-leave-active" ng-if="comboBox.visible" on-click-outside="comboBox.hide">...</div> (Session info: chrome=39.0.2171.71)

How to specify the port and host for ng e2e using configuration

醉酒当歌 提交于 2019-12-23 07:30:07
问题 How do you set the port and host for the ng e2e command using a configuration file? I am aware that it is possible to use the following statement at the command line ng e2e --port <port number> --host <host> This works nicely, but it would be more convenient to set the port and address in the configuration file. I have looked inside .angular-cli.json and found that there is a file called protractor.config.js , I've not been able to figure out what settings to use in that file, there's a

Protractor / Selenium Webdriver : Runtime.executionContextCreated has invalid 'context'

纵饮孤独 提交于 2019-12-23 07:13:36
问题 I use protractor to test Angular2 app. It was working fine and I think I didn't change nothing in conf but now it ends up with this: ... super(opt_error); ^ SessionNotCreatedError: session not created exception from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"4012.1","isDefault":true},"id":1,"name":"","origin":"://"} (Session info: chrome=54.0.2840.71) (Driver info: chromedriver=2.21.371459 ... I work on a Mac OSX 10.11.4, Chrome 54.0.2840.71.

Recommended way to locate parent element in Protractor

梦想的初衷 提交于 2019-12-23 06:57:29
问题 According to the newly published Style Guide, using the by.xpath() locators is considered a bad practice . I'm actually trying to follow the suggestion, but stuck on getting a parent element. Currently we are using .. XPath expression to get to the element's parent: this.dashboard = element(by.linkText("Dashboard")).element(by.xpath("..")); How can I locate the element's parent using other built into Protractor/WebDriverJS locators? 回答1: While I dig the Style Guide, and agree that xpath is to

Unable to load Chrome extension in Protractor tests

跟風遠走 提交于 2019-12-23 05:58:17
问题 Given below is a snippet from config.js capabilities: { 'browserName': 'chrome', 'chromeOptions': { 'args': ['--load-extension=' + '/Users/prashanthsams/Downloads/addon.crx'] } }, Note: I am able to install the .crx extensions manually through Chrome UI and not through automation 来源: https://stackoverflow.com/questions/39605385/unable-to-load-chrome-extension-in-protractor-tests

Protractor capture screenshot on failure

痞子三分冷 提交于 2019-12-23 05:42:09
问题 I have written below code in afterEach method to capture screenshot on failure afterEach(function() { var passed = jasmine.getEnv().currentSpec.results().passed(); if (!passed) { browser.takeScreenshot().then(function(png) { //capturing screenshot here }; } }); But while executing getting below error.. Message: Failed: Cannot read property 'results' of undefined Stack: TypeError: Cannot read property 'results' of undefined how to remove above error... 回答1: currentSpec is not going to work

Protractor capture screenshot on failure

余生长醉 提交于 2019-12-23 05:42:09
问题 I have written below code in afterEach method to capture screenshot on failure afterEach(function() { var passed = jasmine.getEnv().currentSpec.results().passed(); if (!passed) { browser.takeScreenshot().then(function(png) { //capturing screenshot here }; } }); But while executing getting below error.. Message: Failed: Cannot read property 'results' of undefined Stack: TypeError: Cannot read property 'results' of undefined how to remove above error... 回答1: currentSpec is not going to work