I am attempting to automate some testing using Selenium on Chrome. I am running into an issue with selecting radio buttons before moving onto the next step. I am constantly getting a 'NoSuchElementException' error with every method I try for selecting the radio button. Below is the html code that is for the radio buttons, I am trying to select the first "New (Empty)".
<td>
<input type="radio" name="selections" value="emptyAssembly" id="New (Empty)" onclick="onSelection([emptyAssembly, existingAssembly, assemblyFile, virtualDocument], emptyAssembly)">
New (Empty)
<br>
<input type="radio" name="selections" value="existingAssembly" id="Existing Template, Assembly or View" onclick="onSelection([emptyAssembly, existingAssembly, assemblyFile, virtualDocument], existingAssembly)">
Existing Template, Assembly or View
<br>
<input type="radio" name="selections" value="assemblyFile" id="Assembly File" onclick="onSelection([emptyAssembly, existingAssembly, assemblyFile, virtualDocument], assemblyFile)">
Assembly File
<br>
<input type="radio" name="selections" value="virtualDocument" id="Virtual Document" onclick="onSelection([emptyAssembly, existingAssembly, assemblyFile, virtualDocument], virtualDocument)">
Virtual Document
<br>
</td>
Below are a few of the methods I have attempted selecting it wth (the thread sleep is in there as that was a common issue people observed with radio buttons):
Thread.sleep(5000);
webDriver.findElement(By.xpath("//input[@id='New (Empty)']")).click();
Thread.sleep(5000);
webDriver.findElement(By.id("New (Empty)")).click();
I tried others but did not keep track of them, they all threw the same NoSuchElementException error.
I attempted selecting it by creating a List as suggested on other thread below, for this I get an idex error since the list contain nothing:
webDriver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
List<WebElement> methods = webDriver.findElements(By.name("selections"));
methods.get(0).click();