Skip to content
PowerShell module to run a Selenium WebDriver.
PowerShell
Branch: master
Clone or download
Latest commit 85d3182 Aug 21, 2019

README.md

Selenium PowerShell Module

  • Wraps the C# WebDriver for Selenium
  • Easily execute web-based tests
  • Works well with Pester

Installation

Install-Module Selenium

OR

Import-Module "{FullPath}\selenium-powershell\Selenium.psm1"

Usage

Start a Browser Driver

# Start a driver for a browser of your choise (Chrome/Firefox/Edge/InternetExplorer)
# To start a Firefox Driver
$Driver = Start-SeFirefox 

# To start a Chrome Driver
$Driver = Start-SeChrome

# To start an Edge Driver
$Driver = Start-SeEdge

Navigate to a URL

$Driver = Start-SeFirefox 
Enter-SeUrl https://www.poshud.com -Driver $Driver

Find an element

$Driver = Start-SeFirefox 
Enter-SeUrl https://www.poshud.com -Driver $Driver
$Element = Find-SeElement -Driver $Driver -Id "myControl"

Click on a button

$Driver = Start-SeFirefox 
Enter-SeUrl https://www.poshud.com -Driver $Driver
$Element = Find-SeElement -Driver $Driver -Id "btnSend"
Invoke-SeClick -Element $Element

Send Keystrokes

$Driver = Start-SeFirefox 
Enter-SeUrl https://www.poshud.com -Driver $Driver
$Element = Find-SeElement -Driver $Driver -Id "txtEmail"
Send-SeKeys -Element $Element -Keys "adam@poshtools.com"

Run Chrome with options

# Run Chrome in Headless mode 
$Driver = Start-SeChrome -Headless

# Run Chrome in incognito mode
$Driver = Start-SeChrome -Incognito

# Run Chrome with alternative download folder
$Driver = Start-SeChrome -DefaultDownloadPath  c:\temp

Wait for an element

$Driver = Start-SeChrome
Enter-SeUrl https://www.google.com -Driver $Driver
Find-SeElement -Driver $d -Wait -Timeout 10 -Css input[name='q'] 
Find-SeElement -Driver $d -Wait -Timeout 10 -Name q 
You can’t perform that action at this time.