I am trying to access a 2nd or 3rd Checkbox Element that have the same class name and tag..Each of the checkbox is enclosed in a separate div and the div also has the same class name. I previously searched on stackoverflow and Google and tried some of the following but none of them is working
driver.find_element_by_xpath("(//div)[@class='classname value'])[2]")
driver.find_element_by_xpath("(//div[@class='classname value']) [position()=2]")
Also
driver.find_element_by_xpath("(//span)[@class='classname value'])[2]")
driver.find_element_by_xpath("(//span[@class='classname value']) [position()=2]")
This is somehow the elements look like by inspection
<div class='a checkbox'>
<label><input type='checkbox'><span class='b'>Paid</span></label>
</div>
<div class='a checkbox'>
<label><input type='checkbox'><span class='b'>Free</span></label>
</div>
I basically want to access the checkbox with Free Text..My Overall Code is this
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
driver=webdriver.Firefox()
driver.get("http://udemy.com/courses/search/?src=ukw&q=python&p=1")
WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH,"//span[text()='All Filters']"))).click()
time.sleep(10)
WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH,"//div[@class='modal-body']//label[.//span[@data-purpose='filter-option-title' and text()='Free']]/input[@type='checkbox']"))).click()