Hack Forums
[Python] Click the Button on this website using Selenium and Python - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Click the Button on this website using Selenium and Python (/showthread.php?tid=6202689)



Click the Button on this website using Selenium and Python - The Pulp Fiction - Apr 23, 2022

I want to click on the button "Hinzufügen"/"Add to" in this URL using Selenium and python. I tried it with different methods and it's showing the Exception "selenium.common.exceptions.ElementNotInteractableException:". What do you all suggest to make it work?



PS: I have made sure that the element is visible and is shown in the window.


RE: Click the Button on this website using Selenium and Python - SIM-4773582 - Apr 23, 2022

Code
cookie_accept_modal = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.ID, "ensCloseBanner"))
).click()
add_to_cart_button = WebDriverWait(driver, 10).until(
    EC.element_to_be_clickable((By.CSS_SELECTOR, "div[data-testid='desktop'] > div > form > fieldset > div > div:nth-child(2) > button"))
).click()
They have a button for the mobile and one for the desktop version, the mobile button appears first in the dom and is not reachable, i think you were clicking that one.


RE: Click the Button on this website using Selenium and Python - The Pulp Fiction - Apr 24, 2022

(Apr 23, 2022 06:12 PM)Kameleonu Wrote:  
Code
cookie_accept_modal = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.ID, "ensCloseBanner"))
).click()
add_to_cart_button = WebDriverWait(driver, 10).until(
    EC.element_to_be_clickable((By.CSS_SELECTOR, "div[data-testid='desktop'] > div > form > fieldset > div > div:nth-child(2) > button"))
).click()
They have a button for the mobile and one for the desktop version, the mobile button appears first in the dom and is not reachable, i think you were clicking that one.

Thanks bruhh, my chrome is showing me the mobile version instead of the desktop one. I didn't even notice it, u cool 😎👍

Closing this thread, Have a nice day ☺️.