Skip to content

cliu12/selenium-powershell

 
 

Repository files navigation

Selenium PowerShell Module

The Selenium PowerShell module allows you to automate browser interaction using the Selenium API. You can navigate to pages, find elements, click buttons, enter text and even take screenshots.

What's change

  • The is the fork of Adam's Selenium-Powershell 4.0.0.0-Pre3, and make it work with WebDriver.dll 4.0 or later
  • Download the whole Output\Selenium folder
  • Update the binary files inside assemblies as needed
  • Import-Module "Selenium.psd1"

These are the useful links

Looking for Maintainers

I haven't been able to able to keep up with the issues on this repo. If you are interested in becoming a maintainer, please let me know. - Adam

About

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

Build Status

Installation

Note: Firefox's Latest Gecko Driver on Windows requires Microsoft Visual Studio Redistributables for the binary to run get them Here

Install-Module Selenium

OR

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

Usage

Note: in order to use a specific driver you will need to have the brower of the driver installed on your system. For example if you use Start-SeDriver you will need to have either a Chrome or Chromium browser installed

Start a Browser Driver

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

# To start a Chrome Driver
$Driver = Start-SeDriver -Browser Chrome

# To start an Edge Driver
$Driver = Start-SeDriver -Browser Edge

Navigate to a URL

$Driver = Start-SeDriver -Browser Firefox
Set-SeUrl -Url https://www.google.com

Find an Element

$Driver = Start-SeDriver -Browser Firefox
Set-SeUrl https://www.google.com
$Element = Get-SeElement -By CssSelector -Value "textarea[name='q']"

Click on an Element/Button

$Driver = Start-SeDriver -Browser Firefox
Set-SeUrl https://www.google.com
$Element = Get-SeElement -By CssSelector -Value "textarea[name='q']"
Invoke-SeClick -Element $Element

Send Keystrokes

$Driver = Start-SeDriver -Browser Firefox
Set-SeUrl https://www.google.com
$Element = Get-SeElement -By CssSelector -Value "textarea[name='q']"
Invoke-SeKeys -Element $Element -Keys "Selenium{{Enter}}"

Run Chrome with options

# Run Chrome in Headless mode 
$Driver = Start-SeDriver -Browser Chrome -State Headless

# Run Chrome in incognito mode
$Driver = Start-SeDriver -Browser Chrome -State PrivateBrowsing

# Run Chrome with alternative download folder
$Driver = Start-SeDriver -Browser Chrome -DefaultDownloadPath C:\Temp

# Run Chrome and go to a URL in one command
$Driver = Start-SeDriver -Browser Chrome -StartURL 'https://www.google.com/ncr'

# Run Chrome with multiple Arguments
$Driver = Start-SeDriver -Browser Chrome -State PrivateBrowsing -State Maximized

# Run Chrome with an existing profile.
# The default profile paths are as follows:
# Windows: C:\Users\<username>\AppData\Local\Google\Chrome\User Data
# Linux: /home/<username>/.config/google-chrome
# MacOS: /Users/<username>/Library/Application Support/Google/Chrome
$Driver = Start-SeDriver -Browser Chrome -ProfileDirectoryPath '/home/<username>/.config/google-chrome'

Find and Wait for an element

$Driver = Start-SeChrome
Enter-SeUrl 'https://www.google.com/ncr' -Driver $Driver

# Please note that with the -Wait parameter only one element can be returned at a time.
Find-SeElement -Driver $d -Wait -Timeout 10 -Css input[name='q'] 
Find-SeElement -Driver $d -Wait -Timeout 10 -Name q 

Maintainers

About

PowerShell module to run a Selenium WebDriver.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PowerShell 100.0%
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy