Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upFirefox 59 fails to return dom elements #5621
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jimevans
Mar 15, 2018
Member
The W3C WebDriver Specification expressly calls out that attempting to return objects from JavaScript that have cyclic references is disallowed and should return an error. Sounds like Firefox now implements that part of the spec. For what it’s worth, the IE driver will act the same way, so saying “all other browsers” is slightly inaccurate.
|
The W3C WebDriver Specification expressly calls out that attempting to return objects from JavaScript that have cyclic references is disallowed and should return an error. Sounds like Firefox now implements that part of the spec. For what it’s worth, the IE driver will act the same way, so saying “all other browsers” is slightly inaccurate. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
itajaja
Mar 15, 2018
returning dom elements is a pretty common use case though. should we handle the serialization in userland?
itajaja
commented
Mar 15, 2018
|
returning dom elements is a pretty common use case though. should we handle the serialization in userland? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jimevans
Mar 15, 2018
Member
But returning a DOM element doesn't return a node reference in WebDriver. It returns a custom object that is a reference to a DOM element. Returning other types of DOM objects (like "document" or "window"), on the other hand, are especially problematic, and the driver explicitly excludes that case.
|
But returning a DOM element doesn't return a node reference in WebDriver. It returns a custom object that is a reference to a DOM element. Returning other types of DOM objects (like "document" or "window"), on the other hand, are especially problematic, and the driver explicitly excludes that case. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jquense
Mar 15, 2018
How are we supposed to implement custom element locators if we can't return DOM elements from a js run? I'm happy to adjust but it doesn't seem possible any other way?
jquense
commented
Mar 15, 2018
|
How are we supposed to implement custom element locators if we can't return DOM elements from a js run? I'm happy to adjust but it doesn't seem possible any other way? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
itajaja
Mar 15, 2018
btw that would mean that all the protractor's API would have to be rethought? http://www.protractortest.org/#/api?view=ElementFinder or maybe I am missing something
itajaja
commented
Mar 15, 2018
|
btw that would mean that all the protractor's API would have to be rethought? http://www.protractortest.org/#/api?view=ElementFinder or maybe I am missing something |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jimevans
Mar 15, 2018
Member
Folks, don't misunderstand me please. I'm not saying one can't return element references from JavaScript. That has always been the case, and will always continue to work. What I am saying is that if you attempt to return an object from JavaScript that contains circular references, that will now fail. When you return an element reference from JavaScript, you aren't returning the element itself, nor even an JSON serialization of the element. What gets passed back from the driver is just a simple object that represents the element that can be used in subsequent WebDriver calls.
I don't know Protractor well enough to know if they have something in their framework that attempts to return objects from JavaScript execution in the browser* that might contain circular references.
*I realize that Protractor is a JavaScript-based library, so it's all JavaScript execution. What I'm talking about here is JavaScript execution in the browser, as described by driver.executeScript.
|
Folks, don't misunderstand me please. I'm not saying one can't return element references from JavaScript. That has always been the case, and will always continue to work. What I am saying is that if you attempt to return an object from JavaScript that contains circular references, that will now fail. When you return an element reference from JavaScript, you aren't returning the element itself, nor even an JSON serialization of the element. What gets passed back from the driver is just a simple object that represents the element that can be used in subsequent WebDriver calls. I don't know Protractor well enough to know if they have something in their framework that attempts to return objects from JavaScript execution in the browser* that might contain circular references. *I realize that Protractor is a JavaScript-based library, so it's all JavaScript execution. What I'm talking about here is JavaScript execution in the browser, as described by |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jquense
Mar 15, 2018
Sorry I feel like maybe we are misunderstanding each other then. We are saying that returning DOM elements via executeScript is in fact throwing this error.
jquense
commented
Mar 15, 2018
|
Sorry I feel like maybe we are misunderstanding each other then. We are saying that returning DOM elements via |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jimevans
Mar 15, 2018
Member
And what I'm saying is that it's not globally broken, not for Firefox, not for geckodriver. Just yesterday, I ran the Selenium project's .NET test suite using geckodriver 0.20, against Firefox, and it was able to return elements from executeScript calls without difficulty, and without throwing an error.
|
And what I'm saying is that it's not globally broken, not for Firefox, not for geckodriver. Just yesterday, I ran the Selenium project's .NET test suite using geckodriver 0.20, against Firefox, and it was able to return elements from executeScript calls without difficulty, and without throwing an error. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
itajaja
commented
Mar 15, 2018
|
ok, then let me run additional tests and maybe add more reproducibility |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
itajaja
Mar 15, 2018
ok, the problem is that react adds a __reactInternalInstance property on every dom element, and that makes the DOM element contain a circular reference. I am not sure what's the right way to do that. It seems like Firefox is having an expected behavior, but this makes really difficult to fix this problem without some selenium/webdriver change
itajaja
commented
Mar 15, 2018
|
ok, the problem is that react adds a |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
barancev
Mar 16, 2018
Member
Please provide a concise reproducible test case.
I've tried this sample using Selenium 3.11 Java binding, Firefox 61 (Nightly) and geckodriver 0.20 and it works well, no exceptions:
driver.get("https://foxhound87.github.io/mobx-react-form-demo/demo");
WebElement element = (WebElement) driver.executeScript("return document.getElementById('username--20')");
element.sendKeys("Test");
|
Please provide a concise reproducible test case. I've tried this sample using Selenium 3.11 Java binding, Firefox 61 (Nightly) and geckodriver 0.20 and it works well, no exceptions:
|
barancev
added
the
R-awaiting answer
label
Mar 16, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
itajaja
Mar 16, 2018
here is a small repro:
const {Builder, By, Key, until} = require('selenium-webdriver');
(async function example() {
let browser = new Builder()
.forBrowser('firefox')
.usingServer('http://localhost:4444/wd/hub')
.build();
try {
await browser.get('http://todomvc.com/examples/scalajs-react/#/');
const element = await browser.findElement(By.js(`
return document.getElementsByTagName("input")
`));
} finally {
await browser.quit();
}
})();using:
- webdriver-manager 12.0.6
- selenium-webdriver ^4.0.0-alpha.1
- firefox 59
- geckodriver-v0.20.0
- OSX
itajaja
commented
Mar 16, 2018
|
here is a small repro: const {Builder, By, Key, until} = require('selenium-webdriver');
(async function example() {
let browser = new Builder()
.forBrowser('firefox')
.usingServer('http://localhost:4444/wd/hub')
.build();
try {
await browser.get('http://todomvc.com/examples/scalajs-react/#/');
const element = await browser.findElement(By.js(`
return document.getElementsByTagName("input")
`));
} finally {
await browser.quit();
}
})();using:
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
itajaja
Mar 16, 2018
note that if I change the js snippet to return document.getElementsByTagName("input")[0] then it works. as if the array is not cleaned properly maybe?
itajaja
commented
Mar 16, 2018
|
note that if I change the js snippet to |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pittgoose
Mar 18, 2018
@barancev I'm confused why you say you're testing against Firefox 61 when the issue description, and all examples, say Firefox 59. If FF 61 isn't broken it might be safe to assume that they've already fixed this issue in subsequent builds, but I am also seeing this issue in FF 59.
pittgoose
commented
Mar 18, 2018
|
@barancev I'm confused why you say you're testing against Firefox 61 when the issue description, and all examples, say Firefox 59. If FF 61 isn't broken it might be safe to assume that they've already fixed this issue in subsequent builds, but I am also seeing this issue in FF 59. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
barancev
Mar 19, 2018
Member
- Actually, I've tested my sample with both FF 59 (release) and FF 61 (nightly)
- No matter what version of the browser did I try or not, it's not an excuse to not provide a reproduction scenario for the issue :)
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@itajaja |
barancev
added
D-firefox
and removed
R-awaiting answer
labels
Mar 19, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
itajaja
commented
Mar 19, 2018
|
I am glad! so is this a problem with FF59 only or also with nightly? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Both FF 59 (release) and FF 61 (nightly) suffer of this issue. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mbruning24
Mar 19, 2018
Having the same issue, but using the by.repeater('obj in array') syntax with an angular application on FF 59. I believe this uses the same type of logic where it executes a script on the browser.
FF 59.0.1
geckodriver 0.20.0
Selenium 3.11.0
Protractor 5.3.0
EDIT downgraded to FF 58.0.2 and the problem went away.
mbruning24
commented
Mar 19, 2018
•
|
Having the same issue, but using the FF 59.0.1 EDIT downgraded to FF 58.0.2 and the problem went away. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jleyba
Mar 19, 2018
Contributor
@itajaja getElementsByTagName returns a HTMLCollection, not an actual array. Notably:
Array.isArray(document.getElementsByTagName('input')) === falseSince it's not an array, Firefox is probably handling it like an object and finding a cycle (as it would with the DOM). I suspect it would work if you used return Array.from(document.getElementsByTagName("input"))?
|
@itajaja Array.isArray(document.getElementsByTagName('input')) === falseSince it's not an array, Firefox is probably handling it like an object and finding a cycle (as it would with the DOM). I suspect it would work if you used |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jquense
Mar 19, 2018
We tried that @jleyba :/ originally out hunch was actually the opposite, that arrays weren't handled and HtmlCollection's were. But it turns out both aren't.
jquense
commented
Mar 19, 2018
|
We tried that @jleyba :/ originally out hunch was actually the opposite, that arrays weren't handled and HtmlCollection's were. But it turns out both aren't. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Artur-
Mar 22, 2018
Contributor
Ran into the same issue but thought the problem was somewhere else as I have seen similar problems on Edge or IE11. Related to w3c/webdriver#1241 and webcomponents/shadydom#217
My testing indicates that Firefox 58.0.2 works, 59.0b3 and newer do not.
The only workaround I have found so far is to override the JSON serialization of the problematic element properties, e.g. element[key].toJSON = function(){return;}
|
Ran into the same issue but thought the problem was somewhere else as I have seen similar problems on Edge or IE11. Related to w3c/webdriver#1241 and webcomponents/shadydom#217 My testing indicates that Firefox 58.0.2 works, 59.0b3 and newer do not. The only workaround I have found so far is to override the JSON serialization of the problematic element properties, e.g. |
Artur-
referenced this issue
Mar 22, 2018
Open
selectByText method from Combobox element is not working properly #1037
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
barancev
Mar 22, 2018
Member
Raised an issue on the driver: https://bugzilla.mozilla.org/show_bug.cgi?id=1447977
|
Raised an issue on the driver: https://bugzilla.mozilla.org/show_bug.cgi?id=1447977 |
barancev
added
the
R-blocked on external
label
Mar 22, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
monkpit
Apr 4, 2018
I am seeing the same issue in a similar situation - getting elements with protractor on a react page. The problematic method in my code appears to be By.cssContainingText - looks like this is returning an array and iterating over each element to check if it contains the given text. I get the same cyclic object value error when running my tests, but I don't have the opportunity to use the [0] fix mentioned by @itajaja since the array is never directly exposed to me in my code.
Example (on a page running react, in Firefox 59):
element(By.cssContainingText('button', 'click me')).click()
monkpit
commented
Apr 4, 2018
•
|
I am seeing the same issue in a similar situation - getting elements with protractor on a react page. The problematic method in my code appears to be By.cssContainingText - looks like this is returning an array and iterating over each element to check if it contains the given text. I get the same Example (on a page running react, in Firefox 59): |
CoCay
referenced this issue
May 4, 2018
Open
Firefox 59 - Failed: TypeError: cyclic object value #4796
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jerrythimothyj
Jun 21, 2018
Hi, I am facing the same issue:
element(By.$(selector)) is throwing me Failed: TypeError: cyclic object value .
Any updates on this issue?
jerrythimothyj
commented
Jun 21, 2018
|
Hi, I am facing the same issue:
Any updates on this issue? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
whimboo
Jun 26, 2018
Contributor
Raised an issue on the driver: https://bugzilla.mozilla.org/show_bug.cgi?id=1447977
I was not able to reproduce the problem with any of the provided testcases so far. So if you are still able to see this problem with Firefox 61 onwards please comment here and add a reference to a publicly available web page, which reproduces the problem. Thanks.
I was not able to reproduce the problem with any of the provided testcases so far. So if you are still able to see this problem with Firefox 61 onwards please comment here and add a reference to a publicly available web page, which reproduces the problem. Thanks. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
whimboo
Jun 26, 2018
Contributor
Ok, I'm now able to reproduce. All future updates will be visible in the above mentioned bug. I will close this issue when the problem has been fixed.
|
Ok, I'm now able to reproduce. All future updates will be visible in the above mentioned bug. I will close this issue when the problem has been fixed. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@whimboo So this issue can be closed? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
whimboo
Jun 27, 2018
Contributor
No, the bug hasn't been fixed yet. But I'm currently looking into it.
|
No, the bug hasn't been fixed yet. But I'm currently looking into it. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lmtierney
Jun 27, 2018
Member
@whimboo but the bug is not with selenium is it? So we can close this issue in favor of the bugzilla one?
|
@whimboo but the bug is not with selenium is it? So we can close this issue in favor of the bugzilla one? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Feel free to do so in this case. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lmtierney
Jun 28, 2018
Member
Closed in favor of https://bugzilla.mozilla.org/show_bug.cgi?id=1447977
|
Closed in favor of https://bugzilla.mozilla.org/show_bug.cgi?id=1447977 |
lmtierney
closed this
Jun 28, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andreastt
Jul 10, 2018
Member
I’ve just fixed this in https://bugzilla.mozilla.org/show_bug.cgi?id=1447977.
|
I’ve just fixed this in https://bugzilla.mozilla.org/show_bug.cgi?id=1447977. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Awesome! Waiting for Nightly with this fix to test it. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Risce
Jul 11, 2018
I'm having the same issue in Protractor, Firefox 61 using element(by.buttonText("XXX"). I'm not able to click on it.
JavascriptError: TypeError: cyclic object value
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:32:19.891Z'
Risce
commented
Jul 11, 2018
|
I'm having the same issue in Protractor, Firefox 61 using element(by.buttonText("XXX"). I'm not able to click on it. JavascriptError: TypeError: cyclic object value |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Well that build from last month won’t have the fix in it, will it? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Risce
Jul 12, 2018
This error can be reproduced with the basic Protractor example on www.protractortest.org, it is happening when you use Protractor locators.
Risce
commented
Jul 12, 2018
|
This error can be reproduced with the basic Protractor example on |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
barancev
Jul 12, 2018
Member
@Risce Note that the fix has been landed 2 days ago and it's available in Firefox Nightly only at the moment.
|
@Risce Note that the fix has been landed 2 days ago and it's available in Firefox Nightly only at the moment. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
We can probably consider uplifting it to at least beta. I will ask. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Risce
Jul 12, 2018
@barancev @andreastt Thank you for your answer. I tried with the Firefox Nightly and works perfect. Thanks.
Risce
commented
Jul 12, 2018
•
|
@barancev @andreastt Thank you for your answer. I tried with the Firefox Nightly and works perfect. Thanks. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Anojan
Jul 16, 2018
@barancev @andreastt seems the issue still there in nightly as well? I ran my scripts against 62.0b8 (64-bit), and the selenium webdriver I use is 3.4.0
I get the same "JavascriptError: TypeError: cyclic object value" error
Anojan
commented
Jul 16, 2018
|
@barancev @andreastt seems the issue still there in nightly as well? I ran my scripts against 62.0b8 (64-bit), and the selenium webdriver I use is 3.4.0 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andreastt
Jul 16, 2018
Member
@Anojan I can tell from the error message you get that you’re not using the latest Nightly. The error message in Nightly would not contain “TypeError”.
|
@Anojan I can tell from the error message you get that you’re not using the latest Nightly. The error message in Nightly would not contain “TypeError”. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
whimboo
Jul 16, 2018
Contributor
62.0b8 means it is version 62.0 beta 8. If you want a nightly you have to download it from https://www.mozilla.org/en-US/firefox/channel/desktop/#nightly
|
62.0b8 means it is version 62.0 beta 8. If you want a nightly you have to download it from https://www.mozilla.org/en-US/firefox/channel/desktop/#nightly |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Anojan
Jul 17, 2018
@andreastt @whimboo apologies guys, I was using beta version instead, my bad. @andreastt will the fix be applied to beta any soon?
Anojan
commented
Jul 17, 2018
•
|
@andreastt @whimboo apologies guys, I was using beta version instead, my bad. @andreastt will the fix be applied to beta any soon? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andreastt
Jul 17, 2018
Member
@Anojan I think we’re going to hold off uplifting it to beta because we have a suspicion it is causing intermittent timeouts on try.
|
@Anojan I think we’re going to hold off uplifting it to beta because we have a suspicion it is causing intermittent timeouts on try. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
whimboo
Jul 26, 2018
Contributor
Please note that this patch landed on beta now. So with the next Firefox beta release it will be available to use.
|
Please note that this patch landed on beta now. So with the next Firefox beta release it will be available to use. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
steffen-harbich-itc
Sep 7, 2018
Did the firefox release 62 fix your problems? In my case, the line
((JavascriptExecutor) driver).executeScript("return arguments[0].shadowRoot", element);
is still not working for polyfilled shadow DOM of Vaadin flow components:
org.openqa.selenium.JavascriptException: Cyclic object value
steffen-harbich-itc
commented
Sep 7, 2018
|
Did the firefox release 62 fix your problems? In my case, the line |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
whimboo
Sep 7, 2018
Contributor
@steffen-harbich-itc if shadowRoot is not working please file a new geckodriver issue. This is actually something new. Thanks.
|
@steffen-harbich-itc if |
itajaja commentedMar 15, 2018
since the latest firefox version (59) doing a
POST /executecall that returns a DOM element fails with the following:all other browsers, including firefox 58 don't have problems with this. I suppose that this happens because it tries to serialize an object with cyclical references.