[英]Trying to automate to click on Search button in Selenium Python module, but it is not working
[英]Python Selenium trying to click button not working
我正在嘗試使用 CSS 選擇器單擊按鈕。 我嘗試使用帶有值、標題和 onclick 的輸入,但不起作用,這是html 代碼:
<div id="botaoMarcar"><input type="button" disabled class="botao"
value="Marcar todas" title="Marcar todas" onclick="javascript:marcarDesmarcarTodos(true);"
></div>
我的代碼:
driver = Chrome()
url = "https://www3.bcb.gov.br/sgspub/localizarseries/localizarSeries.do?method=prepararTelaLocalizarSeries"
driver.get(url)
try:
WebDriverWait(driver, 3).until(EC.alert_is_present(),
'Timed out waiting for PA creation ' + 'confirmation popup to appear.')
alert = driver.switch_to.alert
alert.accept()
except TimeoutException:
print("No Alert")
driver.implicitly_wait(5)
driver.maximize_window()
# This part is for input table code that I want to access
id_code = driver.find_element(By.ID, 'txCodigo')
id_code.send_keys(24)
id_code.send_keys(Keys.ENTER)
# Part not working exactly
clic_code = driver.find_element(By.CSS_SELECTOR, 'input[value*="Marcar todas"]')
clic_code.click()
您的元素位於 iframe 中。
<iframe id="iCorpo" name="iCorpo" align="center" marginwidth="0" marginheight="0" src="localizarSeries.do?method=recuperarGruposPrincipais" frameborder="0" width="100%" scrolling="auto" height="280" style="height: 399.36px;"></iframe>
只需等待並在找到該元素之前切換到它。
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"#iCorpo")))
進口:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.