Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

ElementFinders should work as params in executeScript calls #1600

Closed
gologox opened this issue Dec 5, 2014 · 4 comments
Closed

ElementFinders should work as params in executeScript calls #1600

gologox opened this issue Dec 5, 2014 · 4 comments

Comments

@gologox
Copy link

gologox commented Dec 5, 2014

The following code causes infinite loop on the selector, i.e :
12:15:11.418 INFO - Executing: [find elements: By.selector: p.note])
12:15:11.424 INFO - Done: [find elements: By.selector: p.note]

it('should scroll into an unhindering page view of all checkboxes', function(done) {
    var bottomElement = element.all(by.css('p.note')).last().then(function(element) {
      return element;
    });
      browser.driver.executeScript("arguments[0].scrollIntoView(true);", bottomElement).then(function() {
        done();
      });
  });

or

it('should scroll into an unhindering page view of all checkboxes', function(done) {
    element.all(by.css('p.note')).last().then(function(element) {
      browser.driver.executeScript("arguments[0].scrollIntoView(true);", element).then(function() {
        done();
      });
    });
  });

or

function scrollIntoView(element) {
  arguments[0].scrollIntoView();
}

it('should scroll into an unhindering page view of all checkboxes', function(done) {
    element.all(by.css('p.note')).last().then(function(element) {
      browser.driver.executeScript(scrollIntoView, element).then(function() {
        done();
      });
    });
  });

_browser.executeScript()_ does the same thing. If I remove the execute script, the code no longer loops infinitely through the selector.

_Note: This was working fine prior to the 1.4.0 update from 1.2.0~_

Any ideas?

@juliemr
Copy link
Member

juliemr commented Dec 5, 2014

This is probably due to f7c3c37 (which is listed as a breaking change in the CHANGELOG)

Fortunately, there's a more concise way to fix this. See an example test at 862a096

Your code would look like:

it('should scroll into an unhindering page view of all checkboxes', function() {
    var bottomElement = element.all(by.css('p.note')).last();
    browser.driver.executeScript("arguments[0].scrollIntoView(true);", bottomElement.getWebElement());
});

@juliemr
Copy link
Member

juliemr commented Dec 5, 2014

However, I'm leaving this issue open because this is hard to discover and it would be great if you didn't have to use the getWebElement call.

hankduan added a commit to hankduan/protractor that referenced this issue Jan 7, 2015
* reuse logic for browser.pause for elementExplorer
* introduce browser.enterRepl
* allow customization of driver for elementExplorer
* fix bug where repl cannot return an ElementFinder (related angular#1600)

Closes angular#1314, angular#1315
hankduan added a commit to hankduan/protractor that referenced this issue Jan 7, 2015
* reuse logic for browser.pause for elementExplorer
* introduce browser.enterRepl
* allow customization of driver for elementExplorer
* fix bug where repl cannot return an ElementFinder (related angular#1600)

Closes angular#1314, angular#1315
hankduan added a commit to hankduan/protractor that referenced this issue Jan 7, 2015
* reuse logic for browser.pause for elementExplorer
* introduce browser.enterRepl
* allow customization of driver for elementExplorer
* fix bug where repl cannot return an ElementFinder (related angular#1600)

Closes angular#1314, angular#1315
hankduan added a commit to hankduan/protractor that referenced this issue Jan 13, 2015
* reuse logic for browser.pause for elementExplorer
* introduce browser.enterRepl
* allow customization of driver for elementExplorer
* fix bug where repl cannot return an ElementFinder (related angular#1600)

Closes angular#1314, angular#1315
hankduan added a commit that referenced this issue Jan 13, 2015
  * reuse logic for browser.pause for elementExplorer
  * introduce browser.enterRepl
  * allow customization of driver for elementExplorer
  * fix bug where repl cannot return an ElementFinder (related #1600)

  Closes #1314, #1315
@juliemr juliemr changed the title element(.css()) & browser.driver.executeScript(s) causing infinite loop after protractor update ElementFinders should work as params in executeScript calls Mar 17, 2015
@juliemr
Copy link
Member

juliemr commented Jul 14, 2016

@mgiambalvo I'm not sure if this works now or not, can you check and let's figure out a workaround if not.

@heathkit
Copy link
Contributor

It works now!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants