Notices: This section not yet converted to new layout. Download stats are rolling back out.

Selenium

3.141.59

Package test results are passing.

This package was approved as a trusted package on 8/3/2019.

Installs and configures selenium standalone, hub, or node server from https://github.com/SeleniumHQ/selenium/.

See https://github.com/dhoer/choco-selenium before attempting to create a hub or node server.

DISCLAIMER: This package is not part of the official Selenium project.

To install Selenium, run the following command from the command line or from PowerShell:

C:\> choco install selenium

To upgrade Selenium, run the following command from the command line or from PowerShell:

C:\> choco upgrade selenium

Files

Hide
  • tools\.skipAutoUninstall
  • tools\capabilities.json Show
    [
      {
        "browserName": "firefox",
        "maxInstances": 5,
        "version": "autoversion",
        "seleniumProtocol": "WebDriver"
      },
      {
        "browserName": "chrome",
        "maxInstances": 5,
        "version": "autoversion",
        "seleniumProtocol": "WebDriver"
      },
      {
        "browserName": "internet explorer",
        "maxInstances": 1,
        "version": "autoversion",
        "seleniumProtocol": "WebDriver"
      }
    ]
    
  • tools\chocolateyInstall.ps1 Show
    $ErrorActionPreference = 'Stop'; # stop on all errors
    
    $toolsDir = Split-Path $MyInvocation.MyCommand.Definition
    . $toolsDir\helpers.ps1
    
    $packageName   = $env:ChocolateyPackageName
    $url           = 'https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar'
    $checksum      = 'acf71b77d1b66b55db6fb0bed6d8bae2bbd481311bcbedfeff472c0d15e8f3cb'
    $checksumType  = 'sha256'
    $toolsLocation = Get-ToolsLocation
    $seleniumDir   = "$toolsLocation\selenium"
    
    $pp            = Get-SeleniumConfigDefaults
    $name          = "Selenium $((Get-Culture).TextInfo.ToTitleCase($pp["role"]))"
    $seleniumPath  = "$seleniumDir\selenium-server-standalone.jar"
    
    if (!(Test-Path $seleniumDir)) {
      New-Item $seleniumDir -ItemType directory -Force
    }
    
    if ($pp["log"]) {
      $logPath  = "$seleniumDir\$($pp["role"]).log"
      Write-Debug "Selenium log: $logPath"
    }
    
    if ($pp["role"] -eq 'node') {
      if ($pp["capabilitiesJson"] -eq $null -or $pp["capabilitiesJson"] -eq '') {
        $pp["capabilitiesJson"] = "$seleniumDir\capabilities.json"
        $capabilitiesPath = "$toolsDir\capabilities.json"
        if (!(Test-Path $pp["capabilitiesJson"])) {
          Copy-Item $capabilitiesPath $pp["capabilitiesJson"]
        }
      }
      # https://stackoverflow.com/a/38212718/4548096
      $pp["capabilities"] = (Get-Content -Path $pp["capabilitiesJson"] -Raw).Replace("`r`n","`n") | ConvertFrom-Json | % { $_ }
      if ($pp["capabilities"] -isnot [Array]) { $pp["capabilities"] = @($pp["capabilities"]) }
      Browser-AutoVersion($pp["capabilities"])
    }
    
    # https://chocolatey.org/docs/helpers-get-chocolatey-web-file
    Get-ChocolateyWebFile $packageName $seleniumPath $url -checksum $checksum -checksumType $checksumType
    
    $config = Get-SeleniumConfig ($pp)
    $configPath = "$seleniumDir\$($pp["role"])config.json"
    
    if ($pp["role"] -ne 'standalone') {
       $config | ConvertTo-Json -Depth 99 | Set-Content $configPath
       Write-Debug "Selenium configuration: $(type $configPath)"
    }
    
    if ($pp["role"] -eq 'hub') {
      $options = "-role hub -hubConfig ""$configPath"""
    } elseif ($pp["role"] -eq 'node' ) {
      $options = "-role node -nodeConfig ""$configPath"""
    } else { # standalone
      $keys = $config.keys
      foreach ($key in $keys) {
        if ($key -eq 'debug') {
          if ($config[$key] -eq $true) { $options += "-$key " }
        } else {
          $options += "-$key "
          if ($config[$key] -is [String] -and $key -ne 'role') {
            $options += """"
            $options += $config[$key]
            $options += """"
          } else {
            $options += $config[$key]
          }
          $options += " "
        }
      }
    }
    
    $cmdParams = "$($pp["javaoptions"]) -jar ""$seleniumPath"" $options"
    $cmd = "java $cmdParams"
    
    Write-Debug "Selenium command: $cmd"
    
    if ($pp["service"] -eq $true) {
      nssm install "$name" java
      nssm set "$name" AppDirectory $seleniumDir
      nssm set "$name" AppParameters $cmdParams
      if ($pp["autostart"] -eq $true) {
        nssm set "$name" Start SERVICE_AUTO_START
      }
      if ($pp["log"]) {
        nssm set "$name" AppStdout $logPath
        nssm set "$name" AppStderr $logPath
        nssm set "$name" AppRotateFiles 1
      }
      nssm start "$name"
    } else {
      $cmdPath = "$seleniumDir\$($pp["role"]).cmd"
    
      if ($pp["log"]) {
    @"
    @echo off
    echo Starting $name...
    for /f %%a in ('powershell -Command "Get-Date -format yyyyMMddTHHmmss"') do set datetime=%%a
    if exist $logPath (
      move /Y $logPath $seleniumDir\$($pp["role"])-%datetime%.log >nul
      echo Rotated previous log
    )
    echo Logging to $logPath
    "@ | Set-Content $cmdPath
        "$cmd > $logPath 2<&1" | Add-Content $cmdPath
      } else {
        $cmd | Set-Content $cmdPath
      }
    
      $menuPrograms = [Environment]::GetFolderPath('Programs')
      $shortcutArgs = @{
        shortcutFilePath = "$menuPrograms\Selenium\$name.lnk"
        targetPath       = $cmdPath
        iconLocation     = "$toolsDir\icon.ico"
        workDirectory    = $seleniumDir
      }
      Install-ChocolateyShortcut @shortcutArgs
    
      if ($pp["autostart"] -eq $true) {
        $startupArgs = @{
          shortcutFilePath = "$menuPrograms\Startup\$name.lnk"
          targetPath       = $cmdPath
          iconLocation     = "$toolsDir\icon.ico"
          workDirectory    = $seleniumDir
        }
        Install-ChocolateyShortcut @startupArgs
      }
    }
    
    $rules = Get-NetFirewallRule
    $par = @{
        DisplayName = "$name"
        LocalPort   = $pp["port"]
        Direction   = "Inbound"
        Protocol    = "TCP"
        Action      = "Allow"
    }
    if (-not $rules.DisplayName.Contains($par.DisplayName)) {New-NetFirewallRule @par}
    
    Write-Debug "Selenium firewall: $par"
    
  • tools\chocolateyUninstall.ps1 Show
    $pp            = Get-PackageParameters
    $toolsLocation = Get-ToolsLocation
    $seleniumDir   = "$toolsLocation\selenium"
    $menuPrograms  = [Environment]::GetFolderPath('Programs')
    $shortcutDir   = "$menuPrograms\Selenium"
    $startupDir    = "$menuPrograms\Startup"
    $names         = @("Selenium Standalone", "Selenium Hub", "Selenium Node")
    
    foreach ($name in $names) {
      $service = Get-WmiObject -Class Win32_Service -Filter "Name='$name'"
    	if ($service -ne $null) {
        nssm remove "$name" confirm
      }
    
      $rules = Get-NetFirewallRule
      if ($rules.DisplayName.Contains($name)) {Remove-NetFirewallRule -DisplayName $name}
    
      if (Test-Path $shortcutDir) {
        $shortcutFile = "$shortcutDir\$name.lnk"
        If (Test-Path $shortcutFile) {
          Remove-Item $shortcutFile -Force
        }
    
        $directoryInfo = Get-ChildItem $shortcutDir | Measure-Object
        If ($directoryInfo.count -eq 0) {
          Remove-Item $shortcutDir -Force
        }
      }
    
      if (Test-Path $startupDir) {
        $startupFile = "$startupDir\$name.lnk"
        If (Test-Path $startupFile) {
          Remove-Item $startupFile -Force
        }
      }
    }
    
    wmic Path win32_process Where "CommandLine Like '%selenium-server-standalone.jar%'" Call Terminate
    
    if ($pp["capabilitiesJson"] -ne $null -and $pp["capabilitiesJson"] -ne '') {
      If (Test-Path $pp["capabilitiesJson"]) {
        Remove-Item $pp["capabilitiesJson"] -Force
      }
    }
    
    if (Test-Path $seleniumDir) {
      $seleniumPath  = "$seleniumDir\selenium-server-standalone.jar"
      if (Test-Path $seleniumPath) {
        Remove-Item $seleniumPath -Force
      }
    
      get-childitem $seleniumDir -include *.cmd -recurse | foreach ($_) {remove-item $_.fullname}
      get-childitem $seleniumDir -include *config.json -recurse | foreach ($_) {remove-item $_.fullname}
      get-childitem $seleniumDir -include *capabilities*.json -recurse | foreach ($_) {remove-item $_.fullname}
      get-childitem $seleniumDir -include *.log -recurse | foreach ($_) {remove-item $_.fullname}
    
      $directoryInfo = Get-ChildItem $seleniumDir | Measure-Object
      If ($directoryInfo.count -eq 0) {
        Remove-Item $seleniumDir -Force
      }
    }
    
  • tools\helpers.ps1 Show
    function Get-SeleniumConfigDefaults {
      $pp = Get-PackageParameters
    
      if ($pp["role"] -eq $null -or $pp["role"] -eq '') { $pp["role"] = 'standalone' }
      if ($pp["username"] -eq $null -or $pp["username"] -eq '') { $pp["username"] = "$env:UserName" }
      if ($pp["port"] -eq $null -or $pp["port"] -eq '') {
        if ($pp["role"] -eq 'node') { $pp["port"] = 5555 } else { $pp["port"] = 4444 }
      }
      if ($pp["log"] -eq $null -or $pp["log"] -eq '') { $pp["log"] = $false }
      if ($pp["service"] -eq $null -or $pp["service"] -eq '') { $pp["service"] = $false }
      if ($pp["autostart"] -eq $null -or $pp["autostart"] -eq '') { $pp["autostart"] = $false }
      if ($pp["debug"] -eq $null -or $pp["debug"] -eq '') { $pp["debug"] = $false }
      if ($pp["browserTimeout"] -eq $null -or $pp["browserTimeout"] -eq '') { $pp["browserTimeout"] = 0 }
      if ($pp["enablePassThrough"] -eq $null -or $pp["enablePassThrough"] -eq '') { $pp["enablePassThrough"] = $true }
      if ($pp["timeout"] -eq $null -or $pp["timeout"] -eq '') { $pp["timeout"] = 1800 }
      if ($pp["capabilityMatcher"] -eq $null -or $pp["capabilityMatcher"] -eq '') { $pp["capabilityMatcher"] = 'org.openqa.grid.internal.utils.DefaultCapabilityMatcher' }
      if ($pp["cleanUpCycle"] -eq $null -or $pp["cleanUpCycle"] -eq '') { $pp["cleanUpCycle"] = 5000 }
      if ($pp["newSessionWaitTimeout"] -eq $null -or $pp["newSessionWaitTimeout"] -eq '') { $pp["newSessionWaitTimeout"] = -1 }
      if ($pp["throwOnCapabilityNotPresent"] -eq $null -or $pp["throwOnCapabilityNotPresent"] -eq '') { $pp["throwOnCapabilityNotPresent"] = $true }
      if ($pp["hub"] -eq $null -or $pp["hub"] -eq '') { $pp["hub"] = 'http://localhost:4444' }
      if ($pp["downPollingLimit"] -eq $null -or $pp["downPollingLimit"] -eq '') { $pp["downPollingLimit"] = 2 }
      if ($pp["maxSession"] -eq $null -or $pp["maxSession"] -eq '') { $pp["maxSession"] = 5 }
      if ($pp["nodePolling"] -eq $null -or $pp["nodePolling"] -eq '') { $pp["nodePolling"] = 5000 }
      if ($pp["nodeStatusCheckTimeout"] -eq $null -or $pp["nodeStatusCheckTimeout"] -eq '') { $pp["nodeStatusCheckTimeout"] = 5000 }
      if ($pp["proxy"] -eq $null -or $pp["proxy"] -eq '') { $pp["proxy"] = 'org.openqa.grid.selenium.proxy.DefaultRemoteProxy' }
      if ($pp["register"] -eq $null -or $pp["register"] -eq '') { $pp["register"] = $true }
      if ($pp["registerCycle"] -eq $null -or $pp["registerCycle"] -eq '') { $pp["registerCycle"] = 5000 }
      if ($pp["unregisterIfStillDownAfter"] -eq $null -or $pp["unregisterIfStillDownAfter"] -eq '') { $pp["unregisterIfStillDownAfter"] = 60000 }
    
      return $pp
    }
    
    function Get-SeleniumConfig ($pp) {
      $config = @{}
    
      $config["role"] = $pp["role"]
      $config["port"] = [int]$pp["port"]
      $config["browserTimeout"] = $pp["browserTimeout"]
      $config["timeout"] = $pp["timeout"]
      $config["debug"] = $pp["debug"]
      $config["enablePassThrough"] = $pp["enablePassThrough"]
    
      if ($pp["jettyMaxThreads"] -ne $null -and $pp["jettyMaxThreads"] -ne '') { $config["jettyMaxThreads"] = $pp["jettyMaxThreads"] }
    
      if ($pp["role"] -eq 'hub') {
        $config["newSessionWaitTimeout"] = $pp["newSessionWaitTimeout"]
        $config["capabilityMatcher"] = $pp["capabilityMatcher"]
        $config["maxSession"] = $pp["maxSession"]
        $config["newSessionWaitTimeout"] = $pp["newSessionWaitTimeout"]
        $config["throwOnCapabilityNotPresent"] = $pp["throwOnCapabilityNotPresent"]
        if ($pp["servlets"] -ne $null) {
          $config["servlets"] = $pp["servlets"]
        }
        if ($pp["withoutServlets"] -ne $null) {
          $config["withoutServlets"] = $pp["withoutServlets"]
        }
        if ($pp["prioritizer"] -ne $null -and $pp["prioritizer"] -ne '') { $config["prioritizer"] = $pp["prioritizer"] }
      } elseif ($pp["role"] -eq 'node' ) {
        $config["cleanUpCycle"] = $pp["cleanUpCycle"]
        $config["downPollingLimit"] = $pp["downPollingLimit"]
        $config["hub"] = $pp["hub"]
        $config["maxSession"] = $pp["maxSession"]
        $config["nodePolling"] = $pp["nodePolling"]
        $config["nodeStatusCheckTimeout"] = $pp["nodeStatusCheckTimeout"]
        $config["proxy"] = $pp["proxy"]
        $config["register"] = $pp["register"]
        $config["registerCycle"] = $pp["registerCycle"]
        $config["unregisterIfStillDownAfter"] = $pp["unregisterIfStillDownAfter"]
        $config["capabilities"] = $pp["capabilities"]
      }
    
      return $config
    }
    
    function Get-ChromeVersion() {
      $root   = 'HKLM:\SOFTWARE\Google\Update\Clients'
      $root64 = 'HKLM:\SOFTWARE\Wow6432Node\Google\Update\Clients'
      foreach ($r in $root,$root64) {
        $gcb = gci $r -ea 0 | ? { (gp $_.PSPath).name -eq 'Google Chrome' }
        if ($gcb) { return $gcb.GetValue('pv') }
      }
    }
    
    function Get-FirefoxVersion() {
      try {
        return iex '&"$env:ProgramFiles\Mozilla Firefox\firefox.exe" -v | more' | %{ [regex]::matches($_, "Mozilla Firefox (.*)") } | %{ $_.Groups[1].Value }
      } catch {
        try {
          return iex '&"$env:ProgramFiles(x86)\Mozilla Firefox\firefox.exe" -v | more' | %{ [regex]::matches($_, "Mozilla Firefox (.*)") } | %{ $_.Groups[1].Value }
        } catch {
          return ""
        }
      }
    }
    
    function Get-InternetExplorerVersion() {
      $reg = 'HKLM:\SOFTWARE\Microsoft\Internet Explorer'
      try {
        return (Get-ItemProperty -Path $reg -Name svcVersion).svcVersion
      }
      catch {
        try {
          return (Get-ItemProperty -Path $reg -Name version).version
        }
        catch {
          return ""
        }
      }
    }
    
    function Get-MicrosoftEdgeVersion() {
      try {
        return Get-AppXPackage -Name *Edge* | Foreach Version
      }
      catch {
        return ""
      }
    }
    
    function Browser-AutoVersion($capabilities) {
      for ($i=0; $i -lt $capabilities.length; $i++) {
        if ($capabilities[$i].version -eq 'autoversion') {
          if ($capabilities[$i].browserName -eq 'firefox') {
            $capabilities[$i].version = Get-FirefoxVersion
          } elseif ($capabilities[$i].browserName -eq 'chrome') {
            $capabilities[$i].version = Get-ChromeVersion
          } elseif  ($capabilities[$i].browserName -eq 'internet explorer') {
            $capabilities[$i].version = Get-InternetExplorerVersion
          } elseif  ($capabilities[$i].browserName -eq 'MicrosoftEdge') {
            $capabilities[$i].version = Get-MicrosoftEdgeVersion
          }
        }
      }
    }
    
  • tools\icon.ico
  • tools\icon.png

Virus Scan Results

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Dependencies

This package has no dependencies.

Package Maintainer(s)

Software Author(s)

  • https://github.com/SeleniumHQ/selenium/blob/master/AUTHORS

Tags

Release Notes

https://github.com/dhoer/choco-selenium/releases

Version History

Version Downloads Last updated Status
Selenium 3.14.0 1996 Wednesday, August 15, 2018 approved
Selenium 3.13.0 651 Wednesday, June 27, 2018 approved
Selenium 3.12.0 371 Thursday, May 31, 2018 approved
Selenium 3.11.0 6686 Monday, March 19, 2018 approved
Selenium 3.10.0 139 Monday, March 19, 2018 approved
Selenium 3.9.1 714 Friday, February 9, 2018 approved
Selenium 3.9.0 167 Tuesday, February 6, 2018 approved
Selenium 3.8.1 3246 Thursday, December 7, 2017 approved
Selenium 3.7.1 270 Tuesday, November 7, 2017 approved
Show More

Discussion for the Selenium Package

Ground rules:

  • This discussion is only about Selenium and the Selenium package. If you have feedback for Chocolatey, please contact the google group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or Selenium, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.

comments powered by Disqus
Chocolatey.org uses cookies to enhance the user experience of the site.
Ok