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

cannot deselect an option in a multi select with click() #1899

Open
lukeis opened this Issue Mar 2, 2016 · 9 comments

Comments

@lukeis
Member

lukeis commented Mar 2, 2016

Originally reported on Google Code with ID 1899

With the HtmlUnit driver at least, click()ing on a selected option in a multiple select
does not deselect it. This needs to work in some fashion because setSelected() is deprecated.

Reported by luke.daley@gradle.biz on 2011-06-22 07:38:26

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Sorry, the issue is that toggle() is deprecated, not setSelected()

Reported by luke.daley@gradle.biz on 2011-06-22 07:39:21

Member

lukeis commented Mar 2, 2016

Sorry, the issue is that toggle() is deprecated, not setSelected()

Reported by luke.daley@gradle.biz on 2011-06-22 07:39:21

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
With FirefoxDriver, clicking a selected option indeed deselects this option. However,
I don't think that tweaking the HtmlUnitDriver to behave the same way is the ultimate
solution, as in a real browser, clicking a selected option does *not* deselect this
option, but all other selected options. 

To be consistent with real browsers, we would actually need to perform some sort of
ctrl+click every time we want to deselect (or toggle) an option. Maybe, we can get
toggle() back?

Reported by jw_google@gmx.de on 2011-06-29 16:20:49

Member

lukeis commented Mar 2, 2016

With FirefoxDriver, clicking a selected option indeed deselects this option. However,
I don't think that tweaking the HtmlUnitDriver to behave the same way is the ultimate
solution, as in a real browser, clicking a selected option does *not* deselect this
option, but all other selected options. 

To be consistent with real browsers, we would actually need to perform some sort of
ctrl+click every time we want to deselect (or toggle) an option. Maybe, we can get
toggle() back?

Reported by jw_google@gmx.de on 2011-06-29 16:20:49

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Behavior is different across browsers. ChromeDriver clicking does not deselect the item
clicked, but FireFoxDriver does. Essentially, ChromeDriver is sending a click, and
FireFoxDriver is sending a CTRL+Click.

This is significant because Ctrl+Click (as far as I know) isn't supported, so ultimately
Chrome can't perform certain functions (for example, deselecting everything in a multiselect
box)

Reported by kevin.t.dillon on 2011-08-08 16:33:04

Member

lukeis commented Mar 2, 2016

Behavior is different across browsers. ChromeDriver clicking does not deselect the item
clicked, but FireFoxDriver does. Essentially, ChromeDriver is sending a click, and
FireFoxDriver is sending a CTRL+Click.

This is significant because Ctrl+Click (as far as I know) isn't supported, so ultimately
Chrome can't perform certain functions (for example, deselecting everything in a multiselect
box)

Reported by kevin.t.dillon on 2011-08-08 16:33:04

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
This continues to happen with Selenium 2.3.1

To save debuggers some time, here is a simple test fails on Chrome but passes on Firefox
with Sel 2.3.1 (FF5, ChromeStable 13.0, chromedriver v14)

        WebElement el = browserDriver.findElement(By.id("multiselect_id"));
        Select sel = new Select(el);
        sel.deselectByIndex(1);
        assertEquals(1, sel.getAllSelectedOptions().size());
        sel.deselectByIndex(2);
        assertEquals(0, sel.getAllSelectedOptions().size());


Test page

<!DOCTYPE html>

<body>
<select id="multiselect_id" name="someMultiSelect" multiple="multiple">
    <option id="opt0" value="opt0">Option 0</option>
    <option id="opt1" value="opt1" selected="selected">Option 1</option>
    <option id="opt2" value="opt2" selected="selected">Option 2</option>
</select>

</body>

Reported by binod80 on 2011-08-08 19:42:17

Member

lukeis commented Mar 2, 2016

This continues to happen with Selenium 2.3.1

To save debuggers some time, here is a simple test fails on Chrome but passes on Firefox
with Sel 2.3.1 (FF5, ChromeStable 13.0, chromedriver v14)

        WebElement el = browserDriver.findElement(By.id("multiselect_id"));
        Select sel = new Select(el);
        sel.deselectByIndex(1);
        assertEquals(1, sel.getAllSelectedOptions().size());
        sel.deselectByIndex(2);
        assertEquals(0, sel.getAllSelectedOptions().size());


Test page

<!DOCTYPE html>

<body>
<select id="multiselect_id" name="someMultiSelect" multiple="multiple">
    <option id="opt0" value="opt0">Option 0</option>
    <option id="opt1" value="opt1" selected="selected">Option 1</option>
    <option id="opt2" value="opt2" selected="selected">Option 2</option>
</select>

</body>

Reported by binod80 on 2011-08-08 19:42:17

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Now already selected options can be deselected via click() also with HtmlUnitDriver.
However, support for that is built into HtmlUnitWebElement#click(), so it still won't
work if the advanced interactions API is used to click the option. Maybe the fix should
be moved to HtmlUnitMouse.

Reported by jw_google@gmx.de on 2011-08-31 14:21:16

Member

lukeis commented Mar 2, 2016

Now already selected options can be deselected via click() also with HtmlUnitDriver.
However, support for that is built into HtmlUnitWebElement#click(), so it still won't
work if the advanced interactions API is used to click the option. Maybe the fix should
be moved to HtmlUnitMouse.

Reported by jw_google@gmx.de on 2011-08-31 14:21:16

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member

Reported by barancev on 2011-10-13 05:14:30

  • Labels added: Component-WebDriver, Browser-HtmlUnit
Member

lukeis commented Mar 2, 2016

Reported by barancev on 2011-10-13 05:14:30

  • Labels added: Component-WebDriver, Browser-HtmlUnit
@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Is this issue still actual? I see all regression tests related to multiselect lists
are green for HtmlUnitDriver.

Reported by barancev on 2013-10-08 20:58:14

  • Status changed: NeedsClarification
Member

lukeis commented Mar 2, 2016

Is this issue still actual? I see all regression tests related to multiselect lists
are green for HtmlUnitDriver.

Reported by barancev on 2013-10-08 20:58:14

  • Status changed: NeedsClarification
@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Just tried with Selenium/Java 2.37.0 and HtmlUnitDriver, FirefoxDriver, and ChromeDriver.
When clicking one of multiple selected options in a multi-select, the option element
gets deselected for HtmlUnitDriver, FirefoxDriver, and ChromeDriver. When doing the
same via the Interactions API, the option element is deselected for HtmlUnitDriver
only. So we still have an inconsistency between drivers.

Furthermore, we have an inconsistency between drivers and real browsers. When clicking
one of multiple selected options in a real browser, the targeted option remains selected,
while all other options get deselected.

Reported by jw_google@gmx.de on 2013-10-23 12:49:39

Member

lukeis commented Mar 2, 2016

Just tried with Selenium/Java 2.37.0 and HtmlUnitDriver, FirefoxDriver, and ChromeDriver.
When clicking one of multiple selected options in a multi-select, the option element
gets deselected for HtmlUnitDriver, FirefoxDriver, and ChromeDriver. When doing the
same via the Interactions API, the option element is deselected for HtmlUnitDriver
only. So we still have an inconsistency between drivers.

Furthermore, we have an inconsistency between drivers and real browsers. When clicking
one of multiple selected options in a real browser, the targeted option remains selected,
while all other options get deselected.

Reported by jw_google@gmx.de on 2013-10-23 12:49:39

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member

Reported by luke.semerau on 2015-09-17 17:44:24

  • Labels added: Restrict-AddIssueComment-Commit
Member

lukeis commented Mar 2, 2016

Reported by luke.semerau on 2015-09-17 17:44:24

  • Labels added: Restrict-AddIssueComment-Commit

@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016

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