Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
923 views
in Technique[技术] by (71.8m points)

automatic date picking selenium

I am working on automating some web related task. For that I am using selenium. However, After trying hours I could not figure out to automate date picking. I have two calendars. See the figure to understand better.

[calendars to pick1

What I am trying to achieve is to choose two dates from the left and right calendar. I want to send two dates and set those dates( also month and year) on those two calendars. I tried to do something like that. I took the xpath for "k-calendar k-first-month" class.

calender_left = driver.find_element_by_xpath('//*[@id="filter-section-timeFilters"]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[1]')
         
ActionChains(driver).move_to_element(calender_left).click().send_keys('02/12/20').perform()

However, no luck on that.

This is how the css elements looks like for the left calendar. enter image description here

Update: I decided to click month and year button using xPath.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Is there any input field to enter date through keyboard?

If YES take xPath or clasName or cssSelector of that element and use sendkeys. Refer the link https://www.browserstack.com/guide/datepicker-in-selenium it will be helpfull.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...