在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中处理页面上的日期和时间选择器。您可以根据具体的日期和时间选择器的实现方式来选择最适合您的方法。