在Selenium中處理頁面日期和時間選擇器時,可以使用以下方法:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get("https://example.com")
date_picker = driver.find_element_by_id("date_picker")
date_picker.send_keys("2022-12-31")
time_picker = driver.find_element_by_id("time_picker")
time_picker.send_keys("12:00 PM")
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://example.com")
driver.execute_script("document.getElementById('date_picker').value = '2022-12-31';")
driver.execute_script("document.getElementById('time_picker').value = '12:00 PM';")
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://example.com")
driver.execute_script("document.getElementById('date_picker').valueAsDate = new Date('2022-12-31');")
driver.execute_script("document.getElementById('time_picker').valueAsDate = new Date('December 31, 2022 12:00:00');");
這些方法可以幫助您在Selenium中處理頁面上的日期和時間選擇器。您可以根據具體的日期和時間選擇器的實現方式來選擇最適合您的方法。