Home > Enterprise >  Getting Selenium Error - selenium.common.exceptions.ElementNotInteractableException: Message: elemen
Getting Selenium Error - selenium.common.exceptions.ElementNotInteractableException: Message: elemen

Time:06-11

I'm getting this error in Selenium when trying to automate registration on a page and I can't figure out how to interact with this button. I can inspect it, find it's XPATH, click it, but I can't get Selenium to do it. I'm able to interact with everything else in the page so far except for this.

button = driver.find_element(by=By.XPATH, value='//*[@id="mobile-title-bar"]/div/button').click()  # click save button

This is the code I'm using and I've also tried using ActionChains but run into the same problem. I'm assuming because the button is in an overlay (see screenshot) but can't get it for some reason. What am I missing here? Edit: I can't share the website URL, it's a service behind a paywall.

Picture of Page with HTML Elements:

enter image description here

Full Error Text:

 Traceback (most recent call last):
  File "C:\Users\Ryan\PycharmProjects\Albert_new_user\main.py", line 45, in <module>
    button = driver.find_element(by=By.XPATH, value='//*[@id="mobile-title-bar"]/div/button').click()  # click save button
  File "C:\Users\Ryan\PycharmProjects\Albert_new_user\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 89, in click
    self._execute(Command.CLICK_ELEMENT)
  File "C:\Users\Ryan\PycharmProjects\Albert_new_user\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 773, in _execute
    return self._parent.execute(command, params)
  File "C:\Users\Ryan\PycharmProjects\Albert_new_user\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 430, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Ryan\PycharmProjects\Albert_new_user\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: chrome=102.0.5005.63)
Stacktrace:
Backtrace:
    Ordinal0 [0x008CD953 2414931]
    Ordinal0 [0x0085F5E1 1963489]
    Ordinal0 [0x0074C580 836992]
    Ordinal0 [0x0077A4F3 1025267]
    Ordinal0 [0x00770293 983699]
    Ordinal0 [0x0079449C 1131676]
    Ordinal0 [0x0076FC74 982132]
    Ordinal0 [0x007946B4 1132212]
    Ordinal0 [0x007A4812 1198098]
    Ordinal0 [0x007942B6 1131190]
    Ordinal0 [0x0076E860 976992]
    Ordinal0 [0x0076F756 980822]
    GetHandleVerifier [0x00B3CC62 2510274]
    GetHandleVerifier [0x00B2F760 2455744]
    GetHandleVerifier [0x0095EABA 551962]
    GetHandleVerifier [0x0095D916 547446]
    Ordinal0 [0x00865F3B 1990459]
    Ordinal0 [0x0086A898 2009240]
    Ordinal0 [0x0086A985 2009477]
    Ordinal0 [0x00873AD1 2046673]
    BaseThreadInitThunk [0x76B2FA29 25]
    RtlGetAppContainerNamedObjectPath [0x76F57A7E 286]
    RtlGetAppCo

ntainerNamedObjectPath [0x76F57A4E 238]

CodePudding user response:

Use this Xpath to click SAVE button

//button[contains(text(),'SAVE')]

CodePudding user response:

Answer that worked from @furas in the comments

I'm not sure but button is without which normally define where to send request after pressing button - and it can make it unclicable. OR maybe it use some JavaScript code to block access when it detect Selenium. You may try to use JavaScript to click it. Soemthing like

driver.execute_script("arguments[0].click()", button)

-furas

  • Related