- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Select date from a datepicker with Selenium Webdriver using Python?
We can select a date from a datepicker with Selenium webdriver using Python. To identify a particular date, first we have to use the find_elements method and identify all the dates having a common locator value.
The find_elements returns a list of matching elements. We have to iterate through this list and search for the date which meets our criteria. Once we get that date, we would select it. Then break out from this iteration.
Example
from selenium import webdriver #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") driver.implicitly_wait(0.5) #launch URL driver.get("https://jqueryui.com/datepicker/") #switch to frame l = driver.find_element_by_xpath("//iframe[@class='demo-frame']") driver.switch_to.frame(l); #identify element inside frame d= driver.find_element_by_id("datepicker") d.click() #identify list of all dates m = driver.find_elements_by_xpath("//table/tbody/tr/td") #iterate over list for i in m: #verify required date then click if i.text == '3': i.click() break #get selected date s = d.get_attribute('value') print("Date entered is: ") print(s) #browser quit driver.quit()
Output
- Related Articles
- How can I select date from a datepicker div using Selenium Webdriver?
- How to Select Value from DropDown using Selenium Webdriver?
- How to select the Date Picker In Selenium WebDriver?
- How to select an item from a dropdown list using Selenium WebDriver with java?
- How to select checkboxes using selenium java webdriver?
- How to get selected option using Selenium WebDriver with Python?
- How to refresh a webpage using Python Selenium Webdriver?
- How install Selenium Webdriver with Python?
- How to deal with ModalDialog using selenium webdriver?
- What are the different ways to select an option from a dropdown using Selenium Webdriver?
- How to scroll down using Selenium WebDriver with Java?
- How to click on a link using Selenium webdriver in Python.
- Handling DropDown And Multiple Select in Webdriver using Selenium
- How to scroll a specific DIV using Selenium WebDriver with Java?
- How to scroll to element with Selenium WebDriver using C#?

Advertisements