You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 29, 2018. It is now read-only.
Here is the html source code of the page:
<!DOCTYPE html>
<html>
<body>
<form action="">
<input type="radio" name="sex" value="female">Male<br>
<input type="radio" name="sex" value="male">Female
</form>
<p>Note: When a user clicks on a radio-button, it becomes checked, and all other radio-buttons
with equal name become unchecked.</p>
</body>
</html>
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_radio
What steps will reproduce the problem?
1. Open the application using selenium webDriver
FirefoxDriver Browser = new FirefoxDriver();
Browser.get("http://www.w3schools.com/html/tryit.asp?filename=tryhtml_radio");
2. Read the text/label of the radio button whose html attribute value="female"
String XPATH = "//input[@value='female']/following-sibling::text()"
String LABEL = Browser.findElement(By.xpath(XPATH)).getText();
3. An InvalidSelectorError exception is raised by WebDriver:
Exception in thread "main" org.openqa.selenium.InvalidSelectorException: The given
selector //input[@value='Red']/following-sibling::text() is either invalid or does
not result in a WebElement. The following error occurred:
InvalidSelectorError: The result of the xpath expression "//input[@value='Red']/following-sibling::text()"
is: [object Text]. It should be an element.
This works fine with Selenium IDE and RC but not with WebDriver.
What is the expected output? What do you see instead?
Ideally it should return the label of the radio button
Selenium version: 2.31.0
OS: Windows XP Professional SP2
Browser: FireFox
Browser version: 19.0.2