Skip to content
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

Page opened through the driver lost field focus #394

Closed
altus34 opened this issue Dec 13, 2016 · 8 comments
Closed

Page opened through the driver lost field focus #394

altus34 opened this issue Dec 13, 2016 · 8 comments

Comments

@altus34
Copy link

altus34 commented Dec 13, 2016

Firefox Version

50.0.2

Platform

Linux

Steps to reproduce -

Open a page with Firefox where a field in a form have the focus by default ex: https://www.google.ca
(the search input have the focus)

Open the same page through the driver and the focus is not here.

@andreastt
Copy link
Contributor

I cannot reproduce this:

>>> m.navigate("https://www.google.ca")
1483022426614	Marionette	TRACE	conn2 -> [0,5,"get",{"url":"https://www.google.ca"}]
>>> 1483022427093	Marionette	TRACE	conn2 <- [1,5,null,{}]

>>> el = m.execute_script("return document.activeElement", sandbox=None)
1483022481247	Marionette	TRACE	conn2 -> [0,7,"executeScript",{"scriptTimeout":null,"newSandbox":true,"args":[],"filename":"<stdin>","script":"return document.activeElement","sandbox":null,"line":1}]
1483022481251	Marionette	TRACE	conn2 <- [1,7,null,{"value":{"element-6066-11e4-a52e-4f735466cecf":"7e740b86-66a5-4bd5-a481-0da1d674f6b2","ELEMENT":"7e740b86-66a5-4bd5-a481-0da1d674f6b2"}}]

>>> el.tag_name
u'input'
>>> 1483022496268	Marionette	TRACE	conn2 -> [0,9,"getElementTagName",{"id":"7e740b86-66a5-4bd5-a481-0da1d674f6b2"}]
1483022496269	Marionette	TRACE	conn2 <- [1,9,null,{"value":"input"}]

@altus34
Copy link
Author

altus34 commented Jan 4, 2017

Sorry to come back to you but your test is not enough.

Can you just open the page https://www.google.ca with Firefox and look that the input field have the focus.
After open the same page with selenium => m.navigate("https://www.google.ca")

Do you have the focus on the input field (I talk visually) ?

FF: 50.0.2
Geckodriver: geckodriver-v0.12.0-linux64
OS: Linux

Thanks

@andreastt
Copy link
Contributor

Yes, as is proven by my snippet.

@altus34
Copy link
Author

altus34 commented Jan 4, 2017

No your script prove just that document.activeElement return to you the input.
Ok so improve the test a little bit ;)

Try this:
1 - Execute the call of this script : "document.activeElement"
We expect to have the input selected.
2 - Now call this script: "document.querySelectorAll(':focus')"

In the case 2 I expect to have an array who contain one element, the same as the first call.
This is not the case with the geckodriver and it's the case with the chromedriver and edgedriver for exemple.

It's very simple to verify in fact. Just open the page with m.navigate("https://www.google.ca")
and type text on your keyboard. The text is added in your URL bar which is focused (you can see a red border).

Can you explain me ?

Thanks

@andreastt
Copy link
Contributor

OK, I think you are right that document.activeElement and document.querySelector(":focus") are different concepts. With some careful testing, ensuring not to invoke focus in any way, I’m able to reproduce this on Linux too.

It seems that the root cause is that we somehow focus the address bar after opening the first window. To ensure proper focus is given to the web content frame (the <xul:browser> element), we ought to focus this after creating a session and upon navigation.

I filed bug 1328676 to fix this.

@altus34
Copy link
Author

altus34 commented Jan 4, 2017

I've a very large test suite to test pretty all features expected for selenium if you want ;)

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jan 6, 2017
…g; r=automatedtester

When a new Marionette session is started, the web content frame (currently
selected <xul:browser> element) is not in focus, causing issues such
as mozilla/geckodriver#394.

This changes the current web content to be selected upon top-level
browsing context navigation and the creation of new sessions.

MozReview-Commit-ID: EgG9gRHtwOA

--HG--
extra : rebase_source : 79c89e2a6d35badf454645bbfb5197a94bb1f980
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jan 7, 2017
…g. r=automatedtester, a=test-only

When a new Marionette session is started, the web content frame (currently
selected <xul:browser> element) is not in focus, causing issues such
as mozilla/geckodriver#394.

This changes the current web content to be selected upon top-level
browsing context navigation and the creation of new sessions.

MozReview-Commit-ID: EgG9gRHtwOA

--HG--
extra : source : 8c25f4454f5bf48257416a1443cd715d44bdd492
@andreastt
Copy link
Contributor

This has now landed on Nightly (53) and Aurora/ESR (52).

JerryShih pushed a commit to JerryShih/gecko-dev that referenced this issue Jan 9, 2017
…g; r=automatedtester

When a new Marionette session is started, the web content frame (currently
selected <xul:browser> element) is not in focus, causing issues such
as mozilla/geckodriver#394.

This changes the current web content to be selected upon top-level
browsing context navigation and the creation of new sessions.

MozReview-Commit-ID: EgG9gRHtwOA
Manishearth pushed a commit to Manishearth/gecko-dev that referenced this issue Jan 10, 2017
…g; r=automatedtester

When a new Marionette session is started, the web content frame (currently
selected <xul:browser> element) is not in focus, causing issues such
as mozilla/geckodriver#394.

This changes the current web content to be selected upon top-level
browsing context navigation and the creation of new sessions.

MozReview-Commit-ID: EgG9gRHtwOA
@lock
Copy link

lock bot commented Aug 17, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have run into an issue you think is related, please open a new issue.

@lock lock bot locked and limited conversation to collaborators Aug 17, 2019
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