I have been fighting with some checkboxes for a couple of days, and finally at the point that I need some assistance. I am using Selenium Webdriver on Chrome, can get through the entire site login, selecting multiple other elements, and selecting from a dropdown box on the same window that these checkboxes are on.
Here is the block of code from the website I am working with, a list of checkboxes: Screenshot of Code - cant embed yet
<div class="panel-body">
<!-- ngRepeat: category in ctrl.categories | orderBy:['Title'] -->
<div class="checkbox ng-scope" ng-repeat="category in ctrl.categories | orderBy:['Title']" style="">
<label style="padding-left: 14px;" class="ng-binding">
<div class="icheckbox_minimal" style="position: relative;">
<input type="checkbox" icheck="" ng-model="ctrl.selectedCategories[category.Code]" class="ng-pristine ng-untouched ng-valid ng-empty" style="position: absolute; opacity: 0;">
<ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;"></ins>
</div>
" Hardscapes "
</label>
</div>
<!-- end ngRepeat: category in ctrl.categories | orderBy:['Title'] -->
<div class="checkbox ng-scope" ng-repeat="category in ctrl.categories | orderBy:['Title']">
<label style="padding-left: 14px;" class="ng-binding">
<div class="icheckbox_minimal" style="position: relative;">
<input type="checkbox" icheck="" ng-model="ctrl.selectedCategories[category.Code]" class="ng-pristine ng-untouched ng-valid ng-empty" style="position: absolute; opacity: 0;">
<ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;"></ins>
</div>
" Irrigation "
</label>
</div>
<!-- end ngRepeat: category in ctrl.categories | orderBy:['Title'] -->
<div class="checkbox ng-scope" ng-repeat="category in ctrl.categories | orderBy:['Title']">
<label style="padding-left: 14px;" class="ng-binding">
<div class="icheckbox_minimal" style="position: relative;">
<input type="checkbox" icheck="" ng-model="ctrl.selectedCategories[category.Code]" class="ng-pristine ng-untouched ng-valid ng-empty" style="position: absolute; opacity: 0;">
<ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;"></ins>
</div>
" Landscape Supplies "
</label>
</div>
<!-- end ngRepeat: category in ctrl.categories | orderBy:['Title'] --><div
Here is a whole bunch of the different attempts I have tried to get selenium to click a checkbox:
WebDriverWait(driver,120).until(EC.visibility_of_element_located((By.CSS_SELECTOR,'.icheckbox_minimal:nth-child[3] input'))).click()
WebDriverWait(driver,120).until(EC.visibility_of_element_located((By.CSS_SELECTOR,'icheckbox_minimal:nth-child[3] input'))).click()
WebDriverWait(driver,120).until(EC.visibility_of_element_located((By.CSS_SELECTOR,'.icheckbox_minimal:nth-of-type(3) input'))).click()
WebDriverWait(driver,120).until(EC.visibility_of_element_located((By.CSS_SELECTOR,'icheckbox_minimal:nth-of-type(3) input'))).click()
WebDriverWait(driver,120).until(EC.visibility_of_element_located((By.XPATH,"//*[@class='panel-body']/div/div[1]/label/input"))).click()
WebDriverWait(driver,120).until(EC.visibility_of_element_located((By.XPATH,"//*[@class='icheckbox_minimal']/div/div[1]/label/input"))).click()
WebDriverWait(driver,120).until(EC.visibility_of_element_located((By.XPATH,"//*[@class='icheckbox_minimal']/div/label/div[3]/input"))).click()
WebDriverWait(driver,120).until(EC.visibility_of_element_located((By.XPATH,"//*[@class='panel-body']/div/label/div[3]/input"))).click()
driver.find_element_by_link_text("Hardscapes").click()
WebDriverWait(driver,120).until(EC.visibility_of_element_located((By.XPATH,'/html/body/div[10]/div/div/div/div[2]/div/div[2]/div/div/div[2]/div[3]'))).click()
WebDriverWait(driver,120).until(EC.visibility_of_element_located((By.CSS_SELECTOR , "panel-body:nth-child(3) input"))).click()
WebDriverWait(driver , 30).until(EC.element_to_be_clickable((By.CSS_SELECTOR , "//div[@class='panel-body']/div/div[3]/label/input"))).click()
driver.find_element_by_css_selector('panel-body:nth-of-type(3) input').click()
WebDriverWait(driver,30).until(EC.element_to_be_clickable((By.CLASS_NAME,"ng-binding"))).click()
WebDriverWait(driver,30).until(EC.visibility_of_element_located((By.XPATH,"//span[contain(text(),'Hardscapes')]"))).click()
Hopefully someone out there can point me in the right direction on what I am missing to get these nested checkboxes checked.
Thanks for any help!
Aucun commentaire:
Enregistrer un commentaire