While my python selenium code works well, I identified several sections of it in which I am waiting to click on an XPATH located item and therefore tried to define a function to do so as follows:
def click_xpath(browser, xpath_string: str):
""" locates a button by XPATH
and clicks on it
"""
WebDriverWait(browser, 10).until(
EC.element_to_be_clickable((By.XPATH, xpath_string))
).click()
return browser
and call it as follows:
driver = click_xpath(driver, "/html/body/div[5]/div[3]/div/button")
but then the next instruction:
find_textbox = driver.find_element_by_id("search")
fails with the following:
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
The previous working code that I attempted substituting by calling my function was:
WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "/html/body/div[5]/div[3]/div/button"))
).click()
which worked well, with subsequent uses of driver proceeding normally.
What am I overlooking? Thanks
PS Assuming this can be done, what type hind should I use for the return object of my function?