Automating Chrome WebDriver – Select Date from DatePicker using PowerShell and Selenium

Many thanks to:

for aspiring me to automate Chrome to perform a redundant task that I perform everyday.

I wish that I could select a date instead of sending keys to a datepicker using Selenium in PowerShell.

As per this weblink this is how they do it using Python. The task is very simple and PowerShell is bloat-free when it comes to dependencies.

Here is the story with all sorts of error which I am unable to solve:

$URL = ""

[OpenQA.Selenium.Chrome.ChromeOptions]$ChromeOptions = New-Object OpenQA.Selenium.Chrome.ChromeOptions
$ChromeOptions.PageLoadStrategy = "eager"
$ChromeDriver = New-Object -TypeName "OpenQA.Selenium.Chrome.ChromeDriver" -ArgumentList @($ChromeOptions)


$Frame = 0
$SelectFrame = $ChromeDriver.SwitchTo().Frame($Frame)


$SelectDate = "15"
$dateWidget = $ChromeDriver.FindElementById("ui-datepicker-div")
$cols = $dateWidget.FindElementByTagName("td")

foreach ($cells in $cols) {
    $date = $cells.getText() 
    if($date -eq $SelectDate) {

Function Stop-ChromeDriver {Get-Process -Name chromedriver -ErrorAction SilentlyContinue | Stop-Process -ErrorAction SilentlyContinue}

Would it be possible using PowerShell too?

Many thanks

One reply on “Automating Chrome WebDriver – Select Date from DatePicker using PowerShell and Selenium”

Thank you for the blog mentions, I honestly don’t know how I got across your question, but I did while googling something else. It’s totally doable in PowerShell, try it like this after you’ve loaded Selenium’s class.

# The following changes the frame, won’t give an ugly error out if it fails:
try {$ChromeDriver.SwitchTo().Frame(0) | Out-Null} catch {}
# For the following, [2] is the month you pick, [2] == March
# For the following, “10” picks the day of the month, in this case, the 10th
Peace! – M6k

Leave a Reply

Your email address will not be published. Required fields are marked *