Problems on Practice Check Box Script

I am a complete newbie trying to learn Selenium webdriver on this website, but have encountered
and error which i cannot resolve. I encountered this on the practice check box page.
I copied the script exactly as on the web page, but getting the following errors

1) bValue = rdBtn_Sex.get(0).isSelected();

.isSelected (); has a red underline and when i hover over it i get the only following option
‘Add cast to rdBtn Sex.get (0)’ . Normally when i hover over an red underline i would get an
to import something or another solution, but don’t know how to resolve this.

2) rdBtn_Sex.get(1).click();

.click (); has a red underline and when i hover over it i get the only following option
‘Add cast to rdBtn Sex.get (1)’

3) if (sValue.equalsIgnoreCase(“Automation Tester”)){
sValue. is highlighted in red, gives me 7 options

4) List rdBtn_Sex = driver.findElements(By.name(“sex”));
List is in yellow and when i hover over it i get the following message

“List is a raw type. References to generic type List<E> should be parameterized”

Any help would be appreciated. Thank you

Ravi12 Default Asked on December 24, 2014 in Selenium WebDriver.
Add Comment
2 Answer(s)

As far as i understand you need to modify your code as :

List <WebElement>  rdBtn_Sex= driver.findElements(By.name(“sex”));”

The WebElement specifies the type you want to have in your collection.”Radio Buttons” in this case.
Once you do this you won’t be getting any red underlines in your code.

Let me know if you still face any issues.

rajesh Supporter Answered on December 29, 2014.
Add Comment

I tried this and I get a red underline for getAttribute part of the following code:

String sValue = chkBx_Profession.get(i).getAttribute(“value”);

Error message – The method getAttribute(String) is undefined for the type Object

StridePurple Default Answered on May 17, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.