admin管理员组

文章数量:1291029

im trying to open a webpage and click a button as soon as it sees it without waiting for the webpage to fully loads

from selenium.webdriver.chrome.service import Serviceenter code here
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdrivermon.by import By

def open_webpage():
   service = Service(ChromeDriverManager().install())
   driver = webdriver.Chrome(service=service)
   driver.get("website_url")
   
   try:
       button = driver.find_element(By.XPATH, '//button[@type="submit" and @data-umami-event="download"]')
       
       if button.is_displayed():
           button.click()
           print("Button clicked")
       else:
           print("Button is not visible.")
       
       from selenium.webdriver.support.ui import WebDriverWait
       from selenium.webdriver.support import expected_conditions as EC
       WebDriverWait(driver, 10).until(
           EC.presence_of_all_elements_located((By.TAG_NAME, 'a'))
       ) ```

本文标签: pythoncan i click a button with selenium without waiting the webpage to fully loadStack Overflow