-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[🐛 Bug]: (Java) S3-S4 W3C Mode Not Supported Using RemoteWebElement to getLocation and getSize #10698
Comments
@BJap, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
@diemol I checked with my team and I can do that. Let me go and open one now. |
…tandard to W3C Standard Fixes SeleniumHQ#10698 as part of SeleniumHQ#10374
…tandard to W3C Standard (#10700) * [Java] Convert RemoteWebElement::getLocation and ::getSize from JWP Standard to W3C Standard Fixes #10698 as part of #10374 * [java] Fixing RemoteWebElementTest unit tests Co-authored-by: Diego Molina <[email protected]> Co-authored-by: Diego Molina <[email protected]> [skip ci]
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. |
…tandard to W3C Standard (SeleniumHQ#10700) * [Java] Convert RemoteWebElement::getLocation and ::getSize from JWP Standard to W3C Standard Fixes SeleniumHQ#10698 as part of SeleniumHQ#10374 * [java] Fixing RemoteWebElementTest unit tests Co-authored-by: Diego Molina <[email protected]> Co-authored-by: Diego Molina <[email protected]> [skip ci]
What happened?
When the user attempts to get a web element's location and size, the code will crash because the command is not supported in W3C mode.
This is due to the fact that unlike JWP, those commands are not supported, and W3C only allows getRect as per spec.
https://w3c.github.io/webdriver/#get-element-rect
Only JWP (not W3C) allows those two as supported commands:
https://www.selenium.dev/documentation/legacy/json_wire_protocol/#sessionsessionidelementidlocation
https://www.selenium.dev/documentation/legacy/json_wire_protocol/#sessionsessionidelementidsize
The code in Selenium 3 should have checked for W3C mode like the Python implementation does, and choose accordingly. Selenium 4 is W3C mode purely and the code should have been migrated to support only that. It is currently still using JWP commands.
This means that the Python and Java implementations are not in sync, and the Java implementation is incorrect. The
getLocation
andgetSize
code for Selenium 4 could just use thegetRect
as a function in both implementations since that's all that's available, and wrap around it to extract the relevant data.Java
Python
---
The solution for Selenium 4 Java (and similarly Python) can just be something like:
or for consistency, this:
In Selenium 3 this was a parameterized choice of one or the other based on whether the test was run in JWP or W3C modes. in Selenium 4, those two functions are basically just helper/wrapper functions.
How can we reproduce the issue?
Visit a webpage (Selenium) or a WebView (Appium) in W3C mode, and attempt to get the size or location of a
WebElement
.webElement.getLocation();
webElement.getSize();
The workaround is to use the API directly as the fix above would suggest and use:
webElement.getRect().getPoint();
webElement.getRect().getDimension();
The problem with this is that a lot of teams that are using this for their testing and want to migrate already have much of their code written in the former use case. It would ease the friction of migration and save lost hours of debugging time to correct the implementation and allow teams to use their code in its existing state without the workaround.
Relevant log output
Description: "Cannot call non W3C standard command while in W3C mode "
When using
getLocation()
--
When using
getSize()
Operating System
Not Applicable but on macOS against Android and iOS
Selenium version
Java Selenium 3 and 4
What are the browser(s) and version(s) where you see this issue?
WebView
What are the browser driver(s) and version(s) where you see this issue?
Available on Request
Are you using Selenium Grid?
No
The text was updated successfully, but these errors were encountered: