Find knowledge base article(s) by searching for keywords in the title e.g. type linux in the search box below
Find knowledge base article(s) by browsing the subject categories of articles
Technology quick references, cheatsheets, user manuals etc.
Shop Online through ShopifyLite
Tutorials on various IT applications.
Search Title    (UL:0 |SS:f)

Scripting >> Selenium >> Powershell >> Getting started with Selenium on Powershell in Windows environment

 

INSTALL Selenium module for powershell


## You need to have internet access and launch Powershell first as administrator


PS C:\WINDOWS\system32> install-module Selenium

 

BROWSER driver


## Not required, but need to have the browser software installed on that windows computer


# 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

 

 TEST RUN


## Create the following sample script and execute with administrator privilege

## If not able to launch powershell script due to Execution policy do


PS C:\WINDOWS\system32> Set-ExecutionPolicy Restricted

c:\scripts\browse.ps1
Import-Module Selenium
$Driver = Start-SeFirefox
Enter-SeUrl -Driver $Driver -Url "http://www.python.org"
$Element = Find-SeElement -Driver $Driver -Id "id-search-field"
Send-SeKeys -Element $Element -Keys "pycon"
$Element.SendKeys([OpenQA.Selenium.Keys]::Enter)

 
## The script should launch Chrome browser, load www.python.org and then search for keyword "pyscon", showing the results

 

 

## Other ways to find the browser element

$Element = Find-SeElement -Driver $Driver -By Name

$Element = Find-SeElement -Driver $Driver -By CssSelector

$Element = Find-SeElement -Driver $Driver -By Id

$Element = Find-SeElement -Driver $Driver -By ClassName

$Element = Find-SeElement -Driver $Driver -By PartialLinkText

$Element = Find-SeElement -Driver $Driver -ByTagName

$Element = Find-SeElement -Driver $Driver -By Path



## e.g. if your search form input field is named SearchInput, then


$Element = Find-SeElement -Driver $Driver -By Name "SearchInput"
Send-SeKeys -Element $Element -Keys "Some keyword to search"
$Element.SendKeys([OpenQA.Selenium.Keys]::Enter)




 

 

 

 

[ © 2008-2021 myfaqbase.com - A property of WPDC Consulting ]