Skip to content

Instantly share code, notes, and snippets.

@lazytesting
Last active July 21, 2016 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazytesting/a47cd7e51557540beb2d368a670def1e to your computer and use it in GitHub Desktop.
Save lazytesting/a47cd7e51557540beb2d368a670def1e to your computer and use it in GitHub Desktop.
run selenium grid

install JDK

1.install chocolatey

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

2.open new cmd window and run

choco install jdk8

Get Selenium and PhantomJS

  1. Download Selenium (Java) http://www.seleniumhq.org/download/ and place the JAR file in a folder
  2. Download PhantomJs http://phantomjs.org/download.html and place it in the same folder note: there is a nasty bug in PhantomJS, so I needed to apply [https://gist.github.com/neuro-sys/41e368839a9b20dafb34](this fix)
  3. place start-selenium-grid.ps1 in the same folder

Run

Execute start-seleniumgrid.ps1, optionally can proivde the commandline argument 'instances' the change the number of PhantomJs instances

param (
[string]$instances = 10
)
# config
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
$seleniumPath = """" + $dir + "\selenium-server-standalone-2.53.1.jar" + """"
$phantomPath = $dir + "\phantomjs.exe"
$startport = 8000
# Start Selenium Hub
Start-Process java -ArgumentList "-jar $seleniumPath -role hub"
# Start PhantomJs instances
Start-Sleep -Seconds 10
$i=0
while($i -ne $instances)
{
$port = $startport + $i
Start-Process -FilePath $phantomPath -ArgumentList "--webdriver=$port --webdriver-selenium-grid-hub=http://127.0.0.1:4444"
$i++
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment