gpt4 book ai didi

python - selenium.common.exceptions.TimeoutException : this error will getting when I'm trying to button click using python

转载 作者:太空宇宙 更新时间:2023-11-03 21:31:27 24 4
gpt4 key购买 nike

我正在使用 Selenium 包来单击网站的按钮。当我尝试时,出现错误:

selenium.common.exceptions.TimeoutException: Message:

这是尝试运行的代码。

import time 
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from bs4 import BeautifulSoup as BSoup
from datetime import date, timedelta
import pyodbc
import datetime

browser = webdriver.Firefox()
browser.get("https://www.cbsl.gov.lk/rates-and-indicators/exchange-rates/daily-buy-and-sell-exchange-rates")
#time.sleep(10)

#browser.find_element_by_xpath('//*[@id="dailyexchange"]/div[2]/div/button[1]').click()

wait = WebDriverWait(browser, 20)
element = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="dailyexchange"]/div[2]/div/button[1]')))
element.click()

最佳答案

点击按钮之前需要切换到 iframe:

browser.get("https://www.cbsl.gov.lk/rates-and-indicators/exchange-rates/daily-buy-and-sell-exchange-rates")
wait = WebDriverWait(browser, 20)
wait.until(EC.frame_to_be_available_and_switch_to_it('iFrameResizer2'))
element = wait.until(EC.element_to_be_clickable((By.NAME, 'select_button')))
element.location_once_scrolled_into_view
element.click()

关于python - selenium.common.exceptions.TimeoutException : this error will getting when I'm trying to button click using python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53493581/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com