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
版权声明:本文标题:python - can i click a button with selenium without waiting the webpage to fully load - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741506817a2382371.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论