0
<button ng-if="vm.signatureRequired" ng-disabled="!vm.signature || vm.signature.length < 2" type="button" aria-hidden="true" data-ng-click="$hide();vm.isAgreement=true;" class="btn btn-default back_btn ng-scope">I Agree</button>

I tried Link_Text, xpath, class..locators but its throwing

"raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: "

2
  • Show code that you've tried already Commented Feb 2, 2017 at 8:57
  • 1 ) driver.find_element_by_class_name("btn btn-default back_btn ng-scope").click() Commented Feb 2, 2017 at 9:03

1 Answer 1

2

Obviously, your selectors (provided in comments) won't work as:

  • You cannot use find_element_by_class_name() with compound class names
  • You cannot apply find_element_by_link_text() to button elements (but a only)

Try to use following code and let me know if exception still occurs:

driver.find_element_by_xpath('//button[text()="I Agree"]').click()

You also might need to add some time to wait until your button become clickable:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.XPATH, '//button[text()="I Agree"]'))).click()

Another way to solve NoSuchElementException is to check whether you r element located inside frame/iframe block. If so, you need to switch to that frame before handling target element:

driver.switch_to_frame('frame_name_or_id')
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.