0

I need a bit a help to randomly select a radio button on an page to answer questions. I am doing some Selenium / Java / webdriver development and sort of new to this. Below is a some code to find the number of radio buttons. any help that someone could provide would be greatly appriciated. if anyone has a better way to accomplish this, don't be shy...

thanks...

driver.switchTo().defaultContent();
		driver.switchTo().frame("mainFrame");
		
		
		List<WebElement> radioButtons = driver.findElements(By.tagName("input"));
		
		for (WebElement radio: radioButtons){
			if (!radio.getAttribute("type").equals("hidden")) {
				log.info("I found the following number of radio buttons "+ radioButtons.size());
				
				}
		}
//		
//		WebElement selectAnswer = driver.findElement(By.tagName("input"));
//		selectAnswer.click();
	}

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by lxXTaCoXxl
0

I'm only in this area to study some Java syntax but did you ever think about using an integer additive to randomize it? Just a thought...

if (helped == yes)
{
cout << "awesome";
}

else
{
cout << "sorry to waste your time";
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.