Protractor: Scroll down

You need to wait for the promise to be solved. The following example comes from an open issue browser.executeScript(‘window.scrollTo(0,0);’).then(function () { page.saveButton.click(); }) Update: This is an old question (May of 2014), but still it is getting some visitors. To clarify: window.scrollTo(0, 0) scrolls to the top left corner of the current page. If you … Read more

Expect item in array

Looks like you need a custom matcher. Depending on the version of Jasmine you are using: With Jasmine 1: this.addMatchers({ toBeIn: function(expected) { var possibilities = Array.isArray(expected) ? expected : [expected]; return possibilities.indexOf(this.actual) > -1; } }); With Jasmine 2: this.addMatchers({ toBeIn: function(util, customEqualityTesters) { return { compare: function(actual, expected) { var possibilities = Array.isArray(expected) … Read more

Browser performance tests through selenium

There is a possibility to get closer to what browser-perf is doing by collecting the chrome performance logs and analyzing them. To get performance logs, turn on performance logs by tweaking loggingPrefs desired capability: from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities caps = DesiredCapabilities.CHROME caps[‘loggingPrefs’] = {‘performance’: ‘ALL’} driver = webdriver.Chrome(desired_capabilities=caps) driver.get(‘https://stackoverflow.com’) logs = … Read more

Accessing Angular inside Protractor Test

There is a function called evaluate(). Find an element in the dom and then run the expression. For example. If you want to count the number of todos in the http://angularjs.org/ website (under Add Some Control), do this: Open the element explorer in protractor ./node_modules/protractor/bin/elementexplorer.js browser.get(‘http://angularjs.org/’) element(by.model(‘todoText’)).evaluate(‘todos.length’). then(function(count) { console.log(count) }); It should give you … Read more