Alright so I have somewhat of a dilemma...
I'm working on a Python script that goes out, hits a url, and clicks a bunch of checkboxes and hits submit. However, I'm having some difficulty clicking the checkbox.
So far, I've been using selenium as my web-interactivity library. I chose this as it seems they had the best option. Here's a gif of what I'm trying to click below. You'll see that when you click one of the boxes, it turns yellow.
Here is an HTML example for the checkbox(s) I'm trying to click:
<li class= "zone odd open night">...</li>
<li class= "zone even open night">...</li>
<li class= "zone odd open night">...</li>
<label for="srr-2-1397538000">Room 226 1:00 AM</label>
<input type="checkbox" name="srr-2-1397538000" id="srr-2-1397538000" value="Y" class="interactive">
<span class-"drag-handle">...</span>
</li>
<li class="zone even open night">...</li>
When I click on the HTML, the html changes so that the class name has "reserving" in it:
<li class= "zone odd open night">...</li>
<li class= "zone even open night">...</li>
<li class= "zone odd reserving night">...</li>
<label for="srr-2-1397538000">Room 226 1:00 AM</label>
<input type="checkbox" name="srr-2-1397538000" id="srr-2-1397538000" value="Y" class="interactive">
<span class-"drag-handle">...</span>
</li>
<li class="zone even open night">...</li>
Here is what I've tried so far but to no avail (just to click that one box as an example):
driver = webdriver.Chrome(executable_path="/Users/grantmcgovern/Dropbox/Developer/Projects/StudyBug/StudyBug.Sheni/chromedriver")
driver.get(url)
assert "ZSR" in driver.title
for i in range(10):
try:
mouse = webdriver.ActionChains(driver)
checkbox = driver.find_element_by_xpath("//label[contains(text(),'Room 228 3:30 AM')]/following-sibling::input")
mouse.move_to_element(checkbox).click()
break
except NoSuchElementException as e:
print('retry in 1s.')
time.sleep(1)
else:
raise e
It simply just doesn't do anything, when it clearly should be clicking the checkbox, (and I would know if it was doing it because the box would turn yellow).
Can anyone give me some pointers as to why it's not working or suggest another method to do this?
Thank You guys