0

Im having a hard time finding the Xpath for the Sign Up button.

I'v tryed using this:

driver.find_element_by_xpath('//input[@type="submit"]').click()

But im reciving this error:

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

Does any one have other ideas on how to click ?

<div class="btn-group"><!-- ngIf: !vm.isSetPassword() --><button class="btn btn-primary ng-scope ng-isolate-scope" ng-if="!vm.isSetPassword()" did-translate="create.SIGN_UP" type="submit">Sign Up</button><!-- end ngIf: !vm.isSetPassword() --></div>

Traceback

    Traceback (most recent call last):
  File "C:\Python-Selenium\ESPN\ESPN-demo\AutomationMain.py", line 19, in <module>
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.btn-group button.btn.btn-primary.ng-scope.ng-isolate-scope[ng-if*='isSetPassword'][did-translate$='SIGN_UP']"))).click()
  File "C:\Users\csalc\AppData\Roaming\Python\Python310\site-packages\selenium\webdriver\support\wait.py", line 89, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 
Stacktrace:
Backtrace:
    Ordinal0 [0x00647413+2389011]
    Ordinal0 [0x005D9F61+1941345]
    Ordinal0 [0x004CC658+837208]
    Ordinal0 [0x004F91DD+1020381]
    Ordinal0 [0x004F949B+1021083]
    Ordinal0 [0x00526032+1204274]
    Ordinal0 [0x00514194+1130900]
    Ordinal0 [0x00524302+1196802]
    Ordinal0 [0x00513F66+1130342]
    Ordinal0 [0x004EE546+976198]
    Ordinal0 [0x004EF456+980054]
    GetHandleVerifier [0x007F9632+1727522]
    GetHandleVerifier [0x008ABA4D+2457661]
    GetHandleVerifier [0x006DEB81+569713]
    GetHandleVerifier [0x006DDD76+566118]
    Ordinal0 [0x005E0B2B+1968939]
    Ordinal0 [0x005E5988+1989000]
    Ordinal0 [0x005E5A75+1989237]
    Ordinal0 [0x005EECB1+2026673]
    BaseThreadInitThunk [0x76B2FA29+25]
    RtlGetAppContainerNamedObjectPath [0x778A7A7E+286]
    RtlGetAppContainerNamedObjectPath [0x778A7A4E+238]


Process finished with exit code 1

1 Answers1

0

The desired element is a Angular element and a dynamic element.

So to click on the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.btn-group button.btn.btn-primary.ng-scope.ng-isolate-scope[ng-if*='isSetPassword'][did-translate$='SIGN_UP']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='btn-group']//button[@class='btn btn-primary ng-scope ng-isolate-scope' and text()='Sign Up']"))).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
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352