Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

isSelected does not work for default select option (HtmlUnit driver) #2295

Closed
lukeis opened this issue Mar 3, 2016 · 5 comments
Closed

isSelected does not work for default select option (HtmlUnit driver) #2295

lukeis opened this issue Mar 3, 2016 · 5 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 2295

I am using selenium-htmlunit-driver-2.4.0 and I want to get all selected options in
a select.

The test fail and looking at the code it seems to be wrong:

In HtmlUnitWebElement:

public boolean isSelected() {
    assertElementNotStale();

    if (element instanceof HtmlInput) {
      return ((HtmlInput) element).isChecked();
    } else if (element instanceof HtmlOption) {
      return ((HtmlOption) element).hasAttribute("selected");
    }

[...]
}

return ((HtmlOption) element).hasAttribute("selected");

should be replaced by

return ((HtmlOption) element).isSelected();

Indeed when you have a select with no options having selected attribute, the first
option is selected by default.

Example:
        <form id="form6">
            <select name="select1">
            <option value="1">one</option>
            <option value="2">two</option>
            <option value="3">three</option>
            </select>
        </form>

Select.getAllSelectedOptions() should return option "one".

Reported by glaurung.aubrane on 2011-08-18 14:33:10

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by dawagner on 2011-08-23 16:43:58

  • Labels added: Browser-HtmlUnit, Component-WebDriver

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Do you need additionnal informations to fix this bug?

Thanks

Reported by glaurung.aubrane on 2011-09-21 13:57:37

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This issue was closed by revision r13942.

Reported by barancev on 2011-09-23 21:04:03

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Issue 2550 has been merged into this issue.

Reported by dawagner on 2011-09-27 19:12:32

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 18:13:30

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 3, 2016
@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.
Projects
None yet
Development

No branches or pull requests

1 participant