My page looks like:
<div class="tabBox">
<table id="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderPM_lstAndroidDeviceType">
<tbody><tr>
<td><input id="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderPM_lstAndroidDeviceType_0" type="checkbox" name="ctl00$ctl00$MainContentPlaceHolder$MainContentPlaceHolderPM$lstAndroidDeviceType$0" value="10"><label for="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderPM_lstAndroidDeviceType_0">1</label></td>
</tr><tr>
<td><input id="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderPM_lstAndroidDeviceType_1" type="checkbox" name="ctl00$ctl00$MainContentPlaceHolder$MainContentPlaceHolderPM$lstAndroidDeviceType$1" value="17"><label for="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderPM_lstAndroidDeviceType_1">2222222</label></td>
</tr><tr>
<td><input id="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderPM_lstAndroidDeviceType_2" type="checkbox" name="ctl00$ctl00$MainContentPlaceHolder$MainContentPlaceHolderPM$lstAndroidDeviceType$2" value="6"><label for="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderPM_lstAndroidDeviceType_2">2323</label></td>
</tr><tr>
<td><input id="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderPM_lstAndroidDeviceType_3" type="checkbox" name="ctl00$ctl00$MainContentPlaceHolder$MainContentPlaceHolderPM$lstAndroidDeviceType$3" value="7"><label for="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderPM_lstAndroidDeviceType_3">232323</label></td>
</tr><tr>
<td><input id="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderPM_lstAndroidDeviceType_4" type="checkbox" name="ctl00$ctl00$MainContentPlaceHolder$MainContentPlaceHolderPM$lstAndroidDeviceType$4" value="12"><label for="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderPM_lstAndroidDeviceType_4">4</label></td>
</tr><tr>
</tbody></table>
</div>
My goal is to create a method that will take a String and and as a result click the corresponding checkbox.
public void toggleDeviceType(String name) {}
toggleDeviceType("nameOfDevice")
How can I select the checkboxes in this div by passing in a name via a String?
note: whats the best way to handle multiple selection here? I don't want the user writing a test outside the framework to be creating an array and adding to it themselves, would rather take care of it in the framework itself
driver.findElement(By.id("ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderPM_lstAndroidDeviceType_4").click();
as a temporary solution to get a successful add and work on some other functionality