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
Amend test_document_element_is_interactable #17769
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The absence of a focus()
method on the Document
interface does not mean it doesn’t receive input events.
When WebDriver uses Element Send Keys on the root document element (<body>
in this case because the document is HTML), the intention is to mimick the behaviour a user would expect if they type into a freshly loaded document where no element has yet been targetted. This mirrors the behaviour outlined in the UI Events standard except WebDriver doesn’t have an explicit notion the default target.
If we look at what UI Events as to say, it is pretty clear that keydown
must be fired regardless of the circumstances, but that its target varies depending on the focussed element and the document type:
Event.target
: focused element processing the key event or if no element focused, then the body element if available, otherwise the root element
The HTML document included by the test also works similarly to me in both Chrome and Firefox, so I think this is a bug in chromedriver.
Deleting the test entirely may have been too rash. The main problem I have with the test is the following line: Instead I propose the following solution (as it seems this assert is trying to ensure the input is not focused): I uploaded a patchset with the change and will change the title of the pull request accordingly |
Thanks for clarifying exactly why this test fails in Chrome. I’m somewhat surprised that
I don’t have time to check the behaviour of Firefox tonight, but can you double-check that |
Yeah sure confirmed that session.active_element returns in Chrome. If you're interested here are some logs: The body id matches with the session.active_element id |
Any update for this? Do you need any more information for this to be pushed through? |
Any updates on this? I made the change suggested by @whimboo |
I'm actually confused by those lines:
Is that the output from the test? Then |
Sorry for the late response. I'll explain the above log.
In Chrome, |
@andreastt This PR is blocked by a requested change from you, though from the conversation it isn't clear to me what additional change is needed. I hope the comments from @julianrkung has explained this PR, but please let me know if you any additional questions or concerns. (@julianrkung is a summer intern who has returned to school, and is no longer actively working on ChromeDriver. I'm trying to help pushing this PR through.) |
Thanks for reminding me to follow up on this.
The test (without this patch applied) assumes the active element is the CSS root element, which in both browsers is I think the change required here is that we should have two tests: one for testing interaction with the document element ( The result of these two tests should be different: in the test for interacting with the document element, sending keys to Generally we should avoid the use of CSS selectors in these tests as it only adds another layer of indirection for figuring out what the test is meant to test. I’m somewhat suspecting the difference in browser behaviour could be an interoperability bug, but for the moment we should allow for both behaviours as they are user-observable. |
Thanks for the clarification. There is actually already a test that verifies interaction with |
@andreastt I moved your pr/17769 branch to pr_17769 because the former tickles a (silly) bug in our sync. I hope that doesn't cause any problems. |
@jgraham we are running only a few tests on this PR. I assume this is happening because we didn't rebase for quite a while? I assume that should be done? |
I'm not able to push to the branch used as source here. As such I've created #38930. |
ChromeDriver was failing this test despite being W3C compliant in this regard. The reason Chrome's webdriver failed was due to Chrome's HTMLDocument not being focusable. In contrast, Firefox's webdriver passes this test because Firefox's HTMLDocument is focusable. According to the W3 spec (linked below), HTMLDocument need not be focusable (can be seen through the absence of the focus method). Therefore this test should be removed since it does not test spec-compliance.
W3 spec:
https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-1006298752