Selenium href 在输入字段后单击
Selenium href click after inputting field
我是 selenium 和 python 的新手,希望能在这里得到一些指导。
我正在尝试输入邮政编码,然后解析显示的结果数据。我遇到的问题是,在输入邮政编码后,我似乎无法点击正确的 href id。
我正在使用 selenium 版本 3.141.0 和 python 3.9.1
我试过的是:
...
inputElement = driver.find_element_by_id('zip_input_region')
inputElement.send_keys(zip)
#Attempt 1 not working
searcher = driver.find_element_by_class_name("cta_btn")
searcher.click()
#Attempt 2 not working
element_to_click = driver.find_element_by_id("zip_submit_region")
driver.execute_script("arguments[0].click();", element_to_click)
#Attempt 3 not working
driver.find_element_by_link_text("Submit").click()
WebDriverWait(driver, 15).until(EC.url_changes(url))
...
我错过了什么?感谢您提供的任何帮助或指导。
提前致谢!
尝试以下等待元素可点击。还添加了选项
options = Options()
options.add_argument('--disable-blink-features=AutomationControlled')
driver = webdriver.Chrome(options=options)
wait = WebDriverWait(driver, 10)
driver.get('https://www.citizensbank.com/custom/RegionializationGateway.aspx?targetpage=/loans/mortgage-refinance.aspx#')
wait.until(EC.element_to_be_clickable((By.ID, "zip_input_region"))).send_keys(zip)
wait.until(EC.element_to_be_clickable((By.ID, "zip_submit_region"))).click()
导入
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
我是 selenium 和 python 的新手,希望能在这里得到一些指导。
我正在尝试输入邮政编码,然后解析显示的结果数据。我遇到的问题是,在输入邮政编码后,我似乎无法点击正确的 href id。
我正在使用 selenium 版本 3.141.0 和 python 3.9.1
我试过的是: ...
inputElement = driver.find_element_by_id('zip_input_region')
inputElement.send_keys(zip)
#Attempt 1 not working
searcher = driver.find_element_by_class_name("cta_btn")
searcher.click()
#Attempt 2 not working
element_to_click = driver.find_element_by_id("zip_submit_region")
driver.execute_script("arguments[0].click();", element_to_click)
#Attempt 3 not working
driver.find_element_by_link_text("Submit").click()
WebDriverWait(driver, 15).until(EC.url_changes(url))
...
我错过了什么?感谢您提供的任何帮助或指导。
提前致谢!
尝试以下等待元素可点击。还添加了选项
options = Options()
options.add_argument('--disable-blink-features=AutomationControlled')
driver = webdriver.Chrome(options=options)
wait = WebDriverWait(driver, 10)
driver.get('https://www.citizensbank.com/custom/RegionializationGateway.aspx?targetpage=/loans/mortgage-refinance.aspx#')
wait.until(EC.element_to_be_clickable((By.ID, "zip_input_region"))).send_keys(zip)
wait.until(EC.element_to_be_clickable((By.ID, "zip_submit_region"))).click()
导入
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options