dimanche 12 novembre 2017

Using CSV to click specific checkboxes using python selenium webdriver

I am still fairly new to the selenium webdriver scene and need some help. I am trying to use a csv file and the value in a specific column to click a specific checkbox on a page using python.
Here are the options for the checkboxes:

<input id="GroupsElected_0" name="GroupsElected" type="checkbox" value="ALL">
<input id="GroupsElected_1" name="GroupsElected" type="checkbox" value="newtest">
<input id="GroupsElected_2" name="GroupsElected" type="checkbox" value="test">

I can make it click the checkbox if I give it the actual value:

group=browser.find_element_by_css_selector("input[type='checkbox'][value='ALL']").click()

What I want to do is make it click the box of the correct one based on the value in my .csv file. I have tried a bunch of different things with no success. I always get invalid selector or cant find the element.
Here's the latest i have:

group2=browser.find_element_by_css_selector("input[type='checkbox'][value=cells[6]]").click()

The value I want from the csv is in the 7th column, I know I can use DictReader and have it read the column names which I will do once I get this working.

HELP?!!




Aucun commentaire:

Enregistrer un commentaire