0

I really tried almost everything that comes on my mind to click on buttons No

Bellow is an entire HTML code of it

<div class="row nest">
   <div class="condition-row clearfix" id="condition_row_1">
      <div class="field small-12 medium-6 columns">
         <label>
         Does this item still have the retail tags attached? <span>*</span>
         </label>
         <div class="btn-group elastic">
            <a class="pill condition-tags btn white sml ">Yes</a><a class="pill condition-tags btn white sml ">No</a>        
         </div>
         <p class="error clearfix" id="condition-tags_error" style="display: none;">Please select an answer</p>
         <input class="required" type="hidden" id="property[condition-tags]" name="property[condition-tags]" value="">
      </div>
      <div class="field small-12 medium-6 empty columns"></div>
   </div>
   <div class="condition-row clearfix" id="condition_row_2">
      <div class="field small-12 medium-6 columns">
         <label>
         Does this item have any signs of wear? <span>*</span>
         </label>
         <div class="btn-group elastic">
            <a class="pill condition-wear btn white sml ">Yes</a><a class="pill condition-wear btn white sml ">No</a>        
         </div>
         <p class="error clearfix" id="condition-wear_error" style="display: none;">Please select an answer</p>
         <input class="required" type="hidden" id="property[condition-wear]" name="property[condition-wear]" value="">
      </div>
      <div class="field small-12 medium-6 empty columns"></div>
   </div>
   <div class="condition-row clearfix" id="condition_row_3">
      <div class="clearfix"></div>
      <div class="field small-12 columns" id="condition-custom-outer" style="display: none;">
         <hr class="hr-line">
         <label>Tag any signs of wear.</label>
         <div class="btn-group elastic">
            <a class="pill condition-list btn white sml ">Scuffs or scratches</a><a class="pill condition-list btn white sml ">Damaged or missing stones</a><a class="pill condition-list btn white sml ">Tarnishing</a>            <a class="condition-add-custom btn white sml" id="condition-add-custom" href="javascript:void(0);">
            <span class="icon-plus-solid"></span>Add your own
            </a>
         </div>
         <div class="clearfix"></div>
         <hr class="hr-line">
         <label>Note</label>
         <textarea class="condition-notes" placeholder="Please describe wear or damage in detail." id="property[condition-note]" name="property[condition-note]"></textarea>
         <input class="customConditions" type="hidden" id="property[condition-list]" name="property[condition-list]" value="">
      </div>
      <div class="field small-12 medium-6 empty columns"></div>
   </div>
</div>

Tried with XPATH,CSS_SELECTOR, LINK_TEXT

All available methods

Seems none of them working.

try:
    WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((By.XPATH,'/html/body/div[3]/div/div/div[2]/form/div[3]/div[2]/div[1]/div/div[2]/div[1]/div[2]/div/div[1]/div[1]/div/a[2]'))).click()
except:
    errorDuringFill = True

Button on screenshot

Using FIREFOX

Live purpose available on : https://www.tradesy.com/sell/

Category : Shoes ... & Accessories & Jewelry & Bracelets

Svetlana Levinsohn
  • 1,550
  • 3
  • 10
  • 19
  • What happens? Does it error out? What error message? Does it quit the session? Is the html code inside an iframe? Did you verify that selenium is seeing the same html that you are? Some sites are blocking selenium now, so verify that all the html is accessible to selenium. – Stuart Mar 14 '20 at 19:14
  • @Stuart I'm able to fill entire form without problems. Only problem is this button here – Rookie programmer Mar 14 '20 at 19:40
  • there were many questions in my comment that you didn't answer. – Stuart Mar 14 '20 at 19:41
  • @Stuart exception type `selenium.common.exceptions.ElementClickInterceptedException` . It's not inside iframe. – Rookie programmer Mar 14 '20 at 19:49
  • 1
    [search the error gave me this, does it help?](https://stackoverflow.com/questions/48665001/can-not-click-on-a-element-elementclickinterceptedexception-in-splinter-selen) – Stuart Mar 14 '20 at 19:51
  • Answer one solved it. You can post it as an answer. Thanks I should learn to use google ... – Rookie programmer Mar 14 '20 at 19:55

3 Answers3

1

This answer taken from: Can not click on a Element: ElementClickInterceptedException in Splinter / Selenium

You can try the below 2 methods to click on element.

element = driver.find_element_by_css('div[class*="loadingWhiteBox"]')
driver.execute_script("arguments[0].click();", element)

element = driver.find_element_by_css('div[class*="loadingWhiteBox"]')
webdriver.ActionChains(driver).move_to_element(element ).click(element ).perform()

hope this will work.

Stuart
  • 465
  • 3
  • 6
0

Try changing the xpath to:

"//div[contains(@class,'condition-row')]//a[contains(.,'No')]"

You should really take some time and read on locators, instead of copying the full path from the inspector - it will make your job easier, and your day happier.

Hrisimir Dakov
  • 557
  • 3
  • 9
  • I agree, but for now this doesn't work `driver.find_element_by_xpath("//div[contains(@class,'condition-row')]//a[contains(.,'No')]").click()` – Rookie programmer Mar 14 '20 at 19:39
  • what is the error your're getting ? always post at-least the exception class when you're seeking assistance, maybe the whole stacktrace if you're feeling lucky :) – Hrisimir Dakov Apr 09 '20 at 20:56
0

I'd try to link to the condition-row class above, just to exclude similar components of that page. And then we can use the class of a and text()

Try this:

driver.implicitly_wait(4)
e = driver.find_element_by_xpath("//div[contains(@class,'condition-row')]//a[contains(@class,'condition-tags') and text()='No']")
e.click()
Svetlana Levinsohn
  • 1,550
  • 3
  • 10
  • 19