Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
933 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...