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

WebElement.click does not work properly with goog.ui.Select #1856

Open
drobota opened this Issue Mar 21, 2016 · 26 comments

Comments

Projects
None yet
6 participants
@drobota

drobota commented Mar 21, 2016

Meta

OS: Any
Selenium Version: 2.48 + (python)
Browser: Only firefox
Browser Version: 43,44,45

Expected Behavior

Menu item should be clicked

Actual Behavior

Click passes however nothing element remains unselected

Run my script and it will fail in combination of any firefox and selenium 2.48+
However it works in chrome, ie11
Moreover if use selenium 2.47.3 or lower and firefox it will work

import unittest
import atexit
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By


TEXT = "Citizen Kane"


class TestGoogSelect(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        wd = webdriver.Firefox()
        atexit.register(wd.quit)
        wd.maximize_window()
        wd.get("https://google.github.io/closure-library/"
               "source/closure/goog/demos/select.html")
        cls.wd = wd

    def test_001(self):
        best_movie_select = self.wd.find_element_by_css_selector(
            "#select1 .goog-menu-button-caption")
        best_movie_select.click()
        menu_items = self.wd.find_elements_by_css_selector(
                                                ".goog-menuitem")
        for item in menu_items:
            if item.is_displayed() and item.text == TEXT:
                item.click()
                print "Item clicked"

        span = WebDriverWait(
                    self.wd, timeout=10).until(
                        EC.visibility_of_element_located(
                            (By.CSS_SELECTOR, "#value1")
                        )
        )

        self.assertIn(TEXT, span.text)


if __name__ == "__main__":
    unittest.main()

PS. I have this problem only during test execution when I try to repro this from python cli it always works

@titusfortner

This comment has been minimized.

Show comment
Hide comment
@titusfortner

titusfortner Mar 22, 2016

Member

Firefox clicking has been updated since 2.48, try with the latest version of Selenium - 2.53.

Member

titusfortner commented Mar 22, 2016

Firefox clicking has been updated since 2.48, try with the latest version of Selenium - 2.53.

@drobota

This comment has been minimized.

Show comment
Hide comment
@drobota

drobota Mar 22, 2016

@titusfortner I've tried lot's of times with different versions
the last one which I used was 2.53.1
Problem was firstly introduced in 2.48 and it presents in all versions which were released after it.

drobota commented Mar 22, 2016

@titusfortner I've tried lot's of times with different versions
the last one which I used was 2.53.1
Problem was firstly introduced in 2.48 and it presents in all versions which were released after it.

@drobota drobota changed the title from Webelemet.click does not work properly with goog.ui.Select to WebElement.click does not work properly with goog.ui.Select Mar 22, 2016

@p0deje

This comment has been minimized.

Show comment
Hide comment
@p0deje

p0deje Mar 22, 2016

Member

I'm pretty sure it is some timing issue (e.g. JS not yet initialized), because I can reproduce the problem using you test case locally, but if I add import time; time.sleep(1) before locating best_movie_select it starts to pass. I'm not sure how changes of Firefox click behavior that were introduced in 2.48 relate to this though.

Closing this as not a Selenium issue.

Member

p0deje commented Mar 22, 2016

I'm pretty sure it is some timing issue (e.g. JS not yet initialized), because I can reproduce the problem using you test case locally, but if I add import time; time.sleep(1) before locating best_movie_select it starts to pass. I'm not sure how changes of Firefox click behavior that were introduced in 2.48 relate to this though.

Closing this as not a Selenium issue.

@p0deje p0deje closed this Mar 22, 2016

@drobota

This comment has been minimized.

Show comment
Hide comment
@drobota

drobota Mar 22, 2016

@p0deje That is definitely selenium issue because it works well in other browsers with different versions of selenium even selenium 2.47 works well with firefox. The problem appears only in selenium 2.48+ and only for Firefox

drobota commented Mar 22, 2016

@p0deje That is definitely selenium issue because it works well in other browsers with different versions of selenium even selenium 2.47 works well with firefox. The problem appears only in selenium 2.48+ and only for Firefox

@p0deje

This comment has been minimized.

Show comment
Hide comment
@p0deje

p0deje Mar 22, 2016

Member

Different browsers have different implementations, some drivers/browsers might be faster that others, so it can lead to potential race condition (not saying that's exactly this case). Significant changes in Selenium 2.48 may also do.

PS. I have this problem only during test execution when I try to repro this from python cli it always works

This also mans that you're hitting race condition.

Member

p0deje commented Mar 22, 2016

Different browsers have different implementations, some drivers/browsers might be faster that others, so it can lead to potential race condition (not saying that's exactly this case). Significant changes in Selenium 2.48 may also do.

PS. I have this problem only during test execution when I try to repro this from python cli it always works

This also mans that you're hitting race condition.

@drobota

This comment has been minimized.

Show comment
Hide comment
@drobota

drobota Mar 22, 2016

Using sleep not the best solution whenever in my cases it won't work 100% in all cases. I have tried out lots of different workaround and no one worked for me well. That is real pain in the ass as we heavily use this component.

drobota commented Mar 22, 2016

Using sleep not the best solution whenever in my cases it won't work 100% in all cases. I have tried out lots of different workaround and no one worked for me well. That is real pain in the ass as we heavily use this component.

@p0deje

This comment has been minimized.

Show comment
Hide comment
@p0deje

p0deje Mar 22, 2016

Member

I'm not suggesting to use sleep, I was just demonstrating that you are facing race condition, which has probably always been there but until 2.48 it was not a problem.

I understand that it's painful, but it has to be handled in client code, not Selenium. If you just want to make the code more reliable without going deeper and trying to understand what causes the issue, you can just click in the loop until select is opened.

Member

p0deje commented Mar 22, 2016

I'm not suggesting to use sleep, I was just demonstrating that you are facing race condition, which has probably always been there but until 2.48 it was not a problem.

I understand that it's painful, but it has to be handled in client code, not Selenium. If you just want to make the code more reliable without going deeper and trying to understand what causes the issue, you can just click in the loop until select is opened.

@drobota

This comment has been minimized.

Show comment
Hide comment
@drobota

drobota Mar 22, 2016

Select always opens and menu-item is being clicked the problem that these actions do not have any affect. I would still insist that it is selenium issue because there is a clear repro case which proves that problem comes from selenium. Because when use firefox 41 and selenium 2.47.3 - test passes. However when update version to 2.48 test fails nevertheless with chrome, safari or ie test passes despite on selenium version.

drobota commented Mar 22, 2016

Select always opens and menu-item is being clicked the problem that these actions do not have any affect. I would still insist that it is selenium issue because there is a clear repro case which proves that problem comes from selenium. Because when use firefox 41 and selenium 2.47.3 - test passes. However when update version to 2.48 test fails nevertheless with chrome, safari or ie test passes despite on selenium version.

@p0deje

This comment has been minimized.

Show comment
Hide comment
@p0deje

p0deje Mar 22, 2016

Member

My bad, I now see that sometimes goog.ui doesn't see action event triggered or FirefoxDriver doesn't trigger it somehow, so I'm reopening this issue and will investigate more.

Sorry for misunderstanding!

Member

p0deje commented Mar 22, 2016

My bad, I now see that sometimes goog.ui doesn't see action event triggered or FirefoxDriver doesn't trigger it somehow, so I'm reopening this issue and will investigate more.

Sorry for misunderstanding!

@p0deje p0deje reopened this Mar 22, 2016

@pumano

This comment has been minimized.

Show comment
Hide comment
@pumano

pumano Mar 24, 2016

#1867 if you mean html select element problem checkout my workaround, maybe it helps you.

pumano commented Mar 24, 2016

#1867 if you mean html select element problem checkout my workaround, maybe it helps you.

@drobota

This comment has been minimized.

Show comment
Hide comment
@drobota

drobota Mar 24, 2016

@punamo That was first what I tried to do but this approach do not work for me

drobota commented Mar 24, 2016

@punamo That was first what I tried to do but this approach do not work for me

@p0deje

This comment has been minimized.

Show comment
Hide comment
@p0deje

p0deje Mar 25, 2016

Member

For the record, I'm trying to nail down this issue and it looked like a bug in atoms, but the test I have created passes and works fine. Will keep debugging.

Member

p0deje commented Mar 25, 2016

For the record, I'm trying to nail down this issue and it looked like a bug in atoms, but the test I have created passes and works fine. Will keep debugging.

@p0deje

This comment has been minimized.

Show comment
Hide comment
@p0deje

p0deje Mar 29, 2016

Member

This is some really weird behavior which only happens when browser window is focused. Unfortunately, I still don't have that to tell you, but can you confirm the bug doesn't reproduce when different window is focused?

Also, Selenium is going to get rid of its own FirefoxDriver implementation in favor of Marionette. Can you try to use it instead (assuming you're already in Firefox 45)?

I will continue investigating the issue, but pretty sure it won't be resolved quick enough.

Member

p0deje commented Mar 29, 2016

This is some really weird behavior which only happens when browser window is focused. Unfortunately, I still don't have that to tell you, but can you confirm the bug doesn't reproduce when different window is focused?

Also, Selenium is going to get rid of its own FirefoxDriver implementation in favor of Marionette. Can you try to use it instead (assuming you're already in Firefox 45)?

I will continue investigating the issue, but pretty sure it won't be resolved quick enough.

@drobota

This comment has been minimized.

Show comment
Hide comment
@drobota

drobota Mar 29, 2016

@p0deje
Thanks for your replay
I did try to run tests in Mozilla Firefox 45.0 + selenium-2.53.1(python) and problem is still present
However I did not use 'marionette' capabilities, I will try it.

drobota commented Mar 29, 2016

@p0deje
Thanks for your replay
I did try to run tests in Mozilla Firefox 45.0 + selenium-2.53.1(python) and problem is still present
However I did not use 'marionette' capabilities, I will try it.

@p0deje

This comment has been minimized.

Show comment
Hide comment
@p0deje

p0deje Mar 29, 2016

Member

Were you running it using Marionette? It can be run both with and without it.

Member

p0deje commented Mar 29, 2016

Were you running it using Marionette? It can be run both with and without it.

@drobota

This comment has been minimized.

Show comment
Hide comment
@drobota

drobota Mar 29, 2016

No I did not however I did run my example and it works! Hope it will work further. Thanks

drobota commented Mar 29, 2016

No I did not however I did run my example and it works! Hope it will work further. Thanks

@p0deje

This comment has been minimized.

Show comment
Hide comment
@p0deje

p0deje Mar 30, 2016

Member

What do you mean "it works"? What have you done to make it work?
On Ср, 30 марта 2016 г. at 0:25, Dmitriy Robota notifications@github.com
wrote:

No I did not however I did run my example and it works! Hope it will work
further. Thanks


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#1856 (comment)

Alex

Member

p0deje commented Mar 30, 2016

What do you mean "it works"? What have you done to make it work?
On Ср, 30 марта 2016 г. at 0:25, Dmitriy Robota notifications@github.com
wrote:

No I did not however I did run my example and it works! Hope it will work
further. Thanks


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#1856 (comment)

Alex

@drobota

This comment has been minimized.

Show comment
Hide comment
@drobota

drobota Mar 30, 2016

I mean that test which I provided works If I use marrionete

drobota commented Mar 30, 2016

I mean that test which I provided works If I use marrionete

@p0deje

This comment has been minimized.

Show comment
Hide comment
@p0deje

p0deje Mar 30, 2016

Member

Cool. Would switching to Marionette in your test suite be a solution for you?

Member

p0deje commented Mar 30, 2016

Cool. Would switching to Marionette in your test suite be a solution for you?

@drobota

This comment has been minimized.

Show comment
Hide comment
@drobota

drobota Mar 30, 2016

I hope that it would work for me but it does not as marionette does not support all features and it does not work stable for instance simple set_window_size does not work properly(mozilla/geckodriver#56)

drobota commented Mar 30, 2016

I hope that it would work for me but it does not as marionette does not support all features and it does not work stable for instance simple set_window_size does not work properly(mozilla/geckodriver#56)

@p0deje

This comment has been minimized.

Show comment
Hide comment
@p0deje

p0deje Mar 30, 2016

Member

Ok, I'll continue investigating the original issue.

Can you confirm that everything works fine when browser window is not
focused?
On Ср, 30 марта 2016 г. at 10:16, Dmitriy Robota notifications@github.com
wrote:

I hope that it would work for me but it does not as marionette does not
support all feature and it does not work stable for instance simple
set_window_size does not work properly(mozilla/geckodriver#56
mozilla/geckodriver#56)


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#1856 (comment)

Alex

Member

p0deje commented Mar 30, 2016

Ok, I'll continue investigating the original issue.

Can you confirm that everything works fine when browser window is not
focused?
On Ср, 30 марта 2016 г. at 10:16, Dmitriy Robota notifications@github.com
wrote:

I hope that it would work for me but it does not as marionette does not
support all feature and it does not work stable for instance simple
set_window_size does not work properly(mozilla/geckodriver#56
mozilla/geckodriver#56)


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#1856 (comment)

Alex

@drobota

This comment has been minimized.

Show comment
Hide comment
@drobota

drobota Mar 30, 2016

Thanks for you effort.
Yeah. I can confirm this I think that is the reason why it does work when I test my code in cli.

drobota commented Mar 30, 2016

Thanks for you effort.
Yeah. I can confirm this I think that is the reason why it does work when I test my code in cli.

@gabecase

This comment has been minimized.

Show comment
Hide comment
@gabecase

gabecase Apr 8, 2016

We are experiencing the same issue issue on the ruby web driver version 2.48+ with goog.ui.Select elements remaining un-selected after a click. We also are able to get our tests to work only when running them locally and clicking outside of our browser to remove focus, this is a huge blocking issue for us as we cant upgrade web driver until we resolve this. Marionette lacking some of the features we need could be an issue as well.

gabecase commented Apr 8, 2016

We are experiencing the same issue issue on the ruby web driver version 2.48+ with goog.ui.Select elements remaining un-selected after a click. We also are able to get our tests to work only when running them locally and clicking outside of our browser to remove focus, this is a huge blocking issue for us as we cant upgrade web driver until we resolve this. Marionette lacking some of the features we need could be an issue as well.

@p0deje

This comment has been minimized.

Show comment
Hide comment
@p0deje

p0deje Apr 8, 2016

Member

@AutomatedTester Do you have any clue about what can be wrong with it?

Member

p0deje commented Apr 8, 2016

@AutomatedTester Do you have any clue about what can be wrong with it?

@gabecase

This comment has been minimized.

Show comment
Hide comment
@gabecase

gabecase Apr 8, 2016

Here is the issue reproduced:
I added a sleep and a hover before we click to show the element is supposed to be selected but after it is clicked you notice the value does not change
(omitted gif but let me know if you want to see the test case get reproduced)

In web driver versions prior to 2.48 this would work with zero problems, no combination of additional waits and changing of selectors in the page object has worked, the only thing that has worked is clicking on a window outside of the browser to lose focus. I cant seem to find anything in the release notes for 2.48 that indicates any of the click behavior has changed.

gabecase commented Apr 8, 2016

Here is the issue reproduced:
I added a sleep and a hover before we click to show the element is supposed to be selected but after it is clicked you notice the value does not change
(omitted gif but let me know if you want to see the test case get reproduced)

In web driver versions prior to 2.48 this would work with zero problems, no combination of additional waits and changing of selectors in the page object has worked, the only thing that has worked is clicking on a window outside of the browser to lose focus. I cant seem to find anything in the release notes for 2.48 that indicates any of the click behavior has changed.

@p0deje

This comment has been minimized.

Show comment
Hide comment
@p0deje

p0deje Apr 11, 2016

Member

Click behavior has been significantly changed in 2.48 and now is mostly happening using Firefox internal APIs. So far I've debugged the issue and it looks like a problem in Firefox itself (or APIs that Selenium use), not the Selenium. I'm not that familiar and after chatting with @barancev we thought that the best you guys could do about this issue is switch to Marionette because current FirefoxDriver won't be supported once Firefox 44esr support is eneded. After that, we're probably going to remove FirefoxDriver from Selenium code and everyone should be prepared to use Marionette by that time.

I'm still willing to fix the issue, but I've hit the wall trying to debug it.

Member

p0deje commented Apr 11, 2016

Click behavior has been significantly changed in 2.48 and now is mostly happening using Firefox internal APIs. So far I've debugged the issue and it looks like a problem in Firefox itself (or APIs that Selenium use), not the Selenium. I'm not that familiar and after chatting with @barancev we thought that the best you guys could do about this issue is switch to Marionette because current FirefoxDriver won't be supported once Firefox 44esr support is eneded. After that, we're probably going to remove FirefoxDriver from Selenium code and everyone should be prepared to use Marionette by that time.

I'm still willing to fix the issue, but I've hit the wall trying to debug it.

@lukeis lukeis added the D-firefox label Oct 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment