-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IE-Driver] "Error executing JavaScript" when accessing TextContent attribute on re-inserted element #6538
Comments
Your suspicion is incorrect, if you got your version of The issue is more likely that version 3.5 and above of the IE driver support the W3C WebDriver Specification. The definition of the "get element attribute" command in the spec has subtle, but very importantly, different semantics than the meaning of that command in the legacy OSS dialect of the protocol. The semantic difference is that the OSS dialect examines both attributes and properties for the appropriate value, while the W3C dialect only examines actual attributes in the markup. Indeed, the above code (attempting to retrieve text by The issue is legitimate, but it's unclear exactly what format the fix for IE should take yet. |
I'm also facing the similar problem when instead of raising exception, it is returning "Error executing javascript" in the similar situation where the element I'm passing is stale. I'm trying to access innerHTML property though, so it looks like a generic issue. I can provide more information is needed. |
@harshg0910 Thank you for the offer of more information. If you could provide Selenium code along with a page (or public URL) which demonstrates the issue, that would be the information required to further debug the issue. |
@jimevans sorry for delay in response, here is the python code snippet to reproduce the issue from selenium import webdriver
driver = webdriver.Ie()
driver.get("http://www.w3schools.com")
element = driver.find_element_by_css_selector('p.w3-text-dark-grey')
# Get inner html of a valid element
html = driver.execute_script("return arguments[0].innerHTML", element)
print(html) # "The language for building web pages"
# Remove element from DOM
driver.execute_script("arguments[0].parentNode.removeChild(arguments[0])", element)
# Get inner html of a stale element
try:
html = driver.execute_script("return arguments[0].tagName", element)
except Exception as ex:
# It throws stale pointer error for first time
print(type(ex))
print(str(ex))
# Bug: From now on, all call returns "Error executing JavaScript" as string without exception
html = driver.execute_script("return arguments[0].innerHTML", element)
print(html) # "Error executing JavaScript" without exception |
I tried this sample with Selenium Python binding 3.141.0 and IEDriverServer 3.141.5.13, the log is:
So you can see it throws an exception, but it is |
I am also getting the same error if the test case is running via Windows Scheduler and the "run whether user is logged on or not" is checked. The same test case is working fine when I logged in and triggering the application manually. We have a .Net windows application by which we are navigating to our web application and login to check the application is up or not. Our application login page have some javascript\jquery to generate text box for user id and password. I logged the html source in a text file while selenium is opening the page when its been called by windows scheduler, the source does not have those textboxes. But when I debugged the same code in Visual Studio, its properly executing the script and generating the textboxes. So it could be a security issue which is blocking javascript when a server is in ideal state. I also used Selenium Grid and RemoteDriver but stuck with the same problem. In our case we cant use any other driver except IE. Code
Server: Windows Server 2012 |
This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stalled for 14 days with no activity. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I have encountered this issue in some custom tests while making an update from v3.4.- to v3.14.0 in order to support latest IE versions.
When attempting to call
IWebElement.GetAttribute
on an element which is removed and re-inserted with JavaScript, the TextContent of the element is "Error executing JavaScript".I suspect it has something to do with this (in IEDriver ChangeLog)
Meta -
OS: Windows 10
Selenium Version: 3.4.0 -> 3.14.0
Browser: IE
Browser Version: 11.285.17134.0
Bindings: C# with custom in house Python wrapper for reliability
Expected Behavior -
Prior to the update, on attribute access of the element, A StaleElementReferenceException is raised. Our custom wrapper catches any Stale pointer exceptions, and re-selects for that element. The element is now "fresh" and attribute access works as expected.
Actual Behavior -
Accessing text attribute on a re-inserted element does not raise StaleElementReferenceException.
Instead, "Error executing JavaScript" is returned.
Steps to reproduce -
GetAttribute("textContent")
The text was updated successfully, but these errors were encountered: