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

element.Selected always returns false in Firefox on Windows Server 2008 #2627

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

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 2627

What steps will reproduce the problem?
1. Run a test that checks a checkbox or clicks a radio button
2. Check element.Selected
3. It returns false even though the checkbox is checked or the radio button is selected

What is the expected output? What do you see instead?
element.Selected should return true if the element is selected.

Selenium version: 2.7
OS: Windows Server 2008 R2 64 bit
Browser: Firefox
Brower version: 6.02
Bindings: dotNet

I haven't tried the latest 2.8 release, I'll try that tomorrow, perhaps the issue is
already resolved.

Reported by anderslyman on 2011-10-06 22:07:36

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Tested with the 2.8 release, issue is still present.

Reported by anderslyman on 2011-10-07 14:17:56

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Can it be .Net specific, or Windows Server specific?

This code works as expected in Java binding on Win7 x64:

driver.get("http://webdesign.about.com/od/examples/l/bl_input-tag-examples.htm");
assertFalse(driver.findElement(By.name("checkbox-un")).isSelected());
assertTrue(driver.findElement(By.name("checkbox-ch")).isSelected());

Reported by barancev on 2011-10-09 19:47:26

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I tried this on a Windows 7 box with the 2.8 .Net bindings and Firefox 6.0, and element.Selected
returns true when it should.

Looks like this is a Windows Server specific issue.

Reported by anderslyman on 2011-10-09 21:26:18

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by barancev on 2011-10-13 09:25:55

  • Status changed: NeedsClarification
  • Labels added: Component-WebDriver, Browser-Firefox, OpSys-Windows

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Do you need clarification on something from me?

Reported by anderslyman on 2011-10-13 14:08:47

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

No clarification needed, we'll try to fix this when we get a chance (or, if you have
the time/motivation, we're always receptive to patches!)

In the mean time, ((JavascriptExecutor)driver).executeScript("return arguments[0].checked",
element); may help you out as a workaround.

Reported by dawagner on 2011-10-14 13:54:41

  • Status changed: New

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

One more thing: please check the sample (that works right on Win7) on your 2008 Server
box to make sure that it is OS-specific issue:

driver.get("http://webdesign.about.com/od/examples/l/bl_input-tag-examples.htm");
assertFalse(driver.findElement(By.name("checkbox-un")).isSelected());
assertTrue(driver.findElement(By.name("checkbox-ch")).isSelected());

Reported by barancev on 2011-10-14 14:08:10

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

The sample you provided worked perfectly on both systems - but my sample still does
not; I did some more digging and found the issue:
Often checkboxes and radio buttons are wrapped in labels:
<label><input type="checkbox"/>I'm a checkbox</label>
(they are wrapped in labels so that clicking on the text selects the checkbox/radio)

I was referencing the label instead of the input node, hence, the click action was
selecting the checkbox , but element.Selected returned false (because the label node
isn't selected - the input node is).

Sorry about the false positive, will you mark this as resolved?  I can see this being
of use to others who run into the same problem.

Reported by anderslyman on 2011-10-14 15:00:01

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Thanks for taking the time :)

Reported by dawagner on 2011-10-14 15:22:30

  • Status changed: Invalid

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

element.isSelected() is always returning false. Checked on both IE8 and FF8

I am not trying to select the label. Instead I am trying to check whether the checkbox
is checked or not. I am using the xpath //table[@id='ws_widget_Checkbox_0']/tbody/tr/td/div[@class='mainSprite
chkBox']

Selenium version: 2.13
OS: Windows XP 32 bit
Browser: Firefox
Brower version: 8

Reported by pradeepta02 on 2011-11-26 15:46:32

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

You are referencing a <div>, not an <input>, WebDriver only recognizes checkboxes made
with <input type='checkbox'> tags.

Reported by anderslyman on 2011-11-26 15:58:58

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Thanks andersly, Fixed the test script accordingly. It's working now.

Reported by pradeepta02 on 2011-11-28 12:04:44

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

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

  • 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