Python Forum
Click on a button on web page using Selenium
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Click on a button on web page using Selenium
#4
Tried to use WebDriverWait.
Doesn't work either.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException, ElementClickInterceptedException
import time

options = Options()
driver = webdriver.Chrome('/usr/bin/chromedriver', options=options)
url = 'https://www.arte.tv/fr/videos/103475-006-A/1-km-a-pied/'
driver.get(url)
timeout = 10

try:
    button_lire_plus = WebDriverWait(driver, timeout).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#__next > div > main > div.css-p6yk9l > div.css-5mui6u > div > button')))
    button_lire_plus.click()
except TimeoutException:
    print('Failed to locate button')
except ElementClickInterceptedException:
    print('Can\'t click on button')
finally:
    driver.quit()

driver.quit()
Here is output in shell:
Output:
>>> RESTART: /home/pavel/python_code/explore_arte_with_selenium_test_click_button_v2.py Can't click on button >>>
Reply


Messages In This Thread
RE: Click on a button on web page using Selenium - by Pavel_47 - Jul-17-2022, 09:53 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  cant click button by script at page michael1834 1 1,211 Dec-08-2023, 04:44 PM
Last Post: SpongeB0B
  Selenium press "select option" button (SOLVED) kucingkembar 0 856 Aug-10-2023, 11:49 AM
Last Post: kucingkembar
  How to make use of this button with selenium? Nohah 0 1,069 Sep-22-2022, 10:22 AM
Last Post: Nohah
  Selenium/Helium loads up a blank web page firaki12345 0 2,107 Mar-23-2021, 11:51 AM
Last Post: firaki12345
  button click error rafarangel 2 3,206 Feb-11-2021, 08:19 PM
Last Post: buran
  Saving html page and reloading into selenium while developing all xpaths Larz60+ 4 4,307 Feb-04-2021, 07:01 AM
Last Post: jonathanwhite1
  Selenium Parsing (unable to Parse page after loading) oneclick 7 6,181 Oct-30-2020, 08:13 PM
Last Post: tomalex
  Selenium Page Object Model with Python Cryptus 5 4,159 Aug-19-2020, 06:30 AM
Last Post: mlieqo
  Selenium on Angular page Martinelli 3 5,878 Jul-28-2020, 12:40 PM
Last Post: Martinelli
  Unable to click element in web page Kalpana 0 1,924 Jun-25-2020, 05:20 AM
Last Post: Kalpana

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020