我試圖在https://www.wg-gesucht.de/en/和後續使用硒的鏈接中輸入表單。下面是我的代碼在表單域中輸入日期
from selenium import webdriver
URL = "https://www.wg-gesucht.de/en/"
driver = webdriver.Chrome(executable_path='chromedriver.exe')
driver.get(URL)
#driver.find_element_by_xpath("//input[@id='date_from_input']").send_keys('31/08/2017')
#driver.find_element_by_xpath("//input[@id='date_to_input']").send_keys('01/09/2017')
driver.find_element_by_xpath("//input[@id='autocompinp']").send_keys('Berlin')
driver.find_element_by_xpath("//button[@id='rubrik-dropdown-menu']").click()
l1 = driver.find_element_by_xpath("//li[@data-text='Flatshares']")
driver.execute_script("arguments[0].click();", l1)
driver.find_element_by_xpath("//button[@id='ang-ges-dropdown-menu']").click()
l2 = driver.find_element_by_xpath("//li[@data-text='Offers']")
driver.execute_script("arguments[0].click();", l2)
driver.find_element_by_xpath("//input[@id='search_button']").click()
driver.find_element_by_xpath("//input[@id='rMax']").send_keys('400')
cmd_d1 = driver.find_element_by_xpath("//input[@id='date_from_input']").value= '31/08/2017'
driver.execute_script(cmd_d1)
cmd_d2 = driver.find_element_by_xpath("//input[@id='date_to_input']").value = '01/09/2017'
driver.execute_script(cmd_d2)
它完美,除了那些隱藏在More Options
按鈕的日期字段。我如何插入值?
崗位培訓相關的HTML請 – Sighil
的HTML太大 –
http://www.wg-gesucht.de/en/wg-zimmer-in-Berlin.8.0.1.0.html –