1

I have tried many ways but driver doesnot clicking my element.

done=driver.find_element_by_xpath("//button[@class='dimapply-btn']")
driver.execute_script("arguments[0].click();", done)

and I have also tried with WebDriverWait.

WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Done']"))).click()

I have also used (x,y) point.

done = driver.find_element_by_xpath('//body')
actions.move_to_element_with_offset(done, 320, 430).click().perform()

My html code is:

<div class="btn-apply" data-ng-click="applyDimensionChanges()" role="button" tabindex="0">
   <button class="dimapply-btn">Done</button>
</div>

It does not throws any errors. just passes by my code and does not click. please help me out. thank you in advance. i am solving this line for two days.

1
  • Javascript executer does not throw any exception, if it is not able to perform the action. Why aren't you using the selenium click() method? Did you check for iframes? Commented Dec 20, 2019 at 9:27

1 Answer 1

1

To click() on the element with text as Done button you can use either of the following Locator Strategies:

  • Using css_selector:

    WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"div.btn-apply[data-ng-click^='applyDimensionChanges']>button.dimapply-btn"))).click()
    
  • Using XPATH:

    WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//div[@class='btn-apply' and starts-with(@data-ng-click, 'applyDimensionChanges')]/button[@class='dimapply-btn' and text()='Done']"))).click()
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.