从弹出选择框更改日期

2024-03-29 11:05:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我想更改turo rental car上的“行程结束”日期,这是我的代码:

from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
options = webdriver.ChromeOptions()
options.add_argument("--user-agent='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36'")
#options.add_argument("headless")
driver=webdriver.Chrome(executable_path="/home/timmy/Python/chromedriver",chrome_options=options)

url="https://turo.com/rentals/cars/co/monument/chevrolet-corvette/524782?searchId=JBjDolXY"
driver.get(url)
#do something afterchanging date

我试过的是

search=driver.find_element_by_xpath('//*[@id="pageContainer-content"]/div[4]/div[3]/div[2]/div[1]/form/div[1]/div/div/div[2]/div/div/div/div/input')
#search.setAttribute("value":"2019-03-15")
#search.send_keys('2019-03-15')
#search.setText("2019-03-15")

但似乎什么都没变,我也试过search.click()它弹出日期但不能编辑,有没有办法不用pyautogui点击它。 我想要的是选择第二天总是(截至发帖的问题日期是3月13日所以3月14日),如果14去15等

感谢您的帮助


Tags: fromimportdivaddsupportsearchbydriver