You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

updateSeleniumDriver.ps1 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing,
  13. # software distributed under the License is distributed on an
  14. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. # KIND, either express or implied. See the License for the
  16. # specific language governing permissions and limitations
  17. # under the License.
  18. #
  19. #
  20. # Powershell script updating Selenium drivers on ci server
  21. #
  22. # Author: Martin Stockhammer <martin_s@apache.org>
  23. # Date : 2017-05-14
  24. #
  25. # Description:
  26. # This script checks, if the selenium drivers are available on the system and downloads
  27. # and extracts them, if they do not exist.
  28. #
  29. # Parameter:
  30. # -Verbose: Print additional output
  31. # -Force: Remove the existing drivers and download/extract them again
  32. param (
  33. [switch]$Verbose = $False,
  34. [switch]$Force = $False
  35. )
  36. $psVersion = $PSVersionTable.PSVersion
  37. $baseDir = "F:\jenkins\tools"
  38. if ($Verbose) {
  39. Write-Output "PS-Version: $psVersion"
  40. Write-Output "Verbose: $Verbose, Force: $Force"
  41. }
  42. $urls = @{
  43. "iedriver\2.53.1\win64\DriverServer.zip"="http://selenium-release.storage.googleapis.com/2.53/IEDriverServer_x64_2.53.1.zip"
  44. "iedriver\2.53.1\win32\DriverServer.zip"="http://selenium-release.storage.googleapis.com/2.53/IEDriverServer_Win32_2.53.1.zip"
  45. "iedriver\3.4.0\win64\DriverServer.zip"="http://selenium-release.storage.googleapis.com/3.4/IEDriverServer_x64_3.4.0.zip"
  46. "iedriver\3.4.0\win32\DriverServer.zip"="http://selenium-release.storage.googleapis.com/3.4/IEDriverServer_Win32_3.4.0.zip"
  47. "chromedriver\2.29\win32\DriverServer.zip"="http://chromedriver.storage.googleapis.com/2.29/chromedriver_win32.zip"
  48. "geckodriver\0.16.1\win32\DriverServer.zip"="http://github.com/mozilla/geckodriver/releases/download/v0.16.1/geckodriver-v0.16.1-win32.zip"
  49. "geckodriver\0.16.1\win64\DriverServer.zip"="http://github.com/mozilla/geckodriver/releases/download/v0.16.1/geckodriver-v0.16.1-win64.zip"
  50. }
  51. foreach ($h in $urls.GetEnumerator()) {
  52. $url = $h.Value
  53. $downloadFile = "$($baseDir)\$($h.Name)"
  54. $downloadDir = Split-Path $downloadFile -Parent
  55. if ($Force -And (Test-Path -Path $downloadDir ) ) {
  56. Get-ChildItem -Path $downloadDir -Recurse | Remove-Item -force -recurse
  57. }
  58. if(!(Test-Path -Path $downloadDir )){
  59. New-Item -ItemType directory -Path $downloadDir
  60. }
  61. if ($Force -Or !(Test-Path -Path $downloadFile )){
  62. Write-Output "Downloading Driver $url"
  63. Invoke-WebRequest -Uri $url -OutFile $downloadFile
  64. $shell = New-Object -ComObject shell.application
  65. $zip = $shell.NameSpace($downloadFile)
  66. foreach ($item in $zip.items()) {
  67. $shell.Namespace($downloadDir).CopyHere($item)
  68. }
  69. if ($Verbose) {
  70. Get-ChildItem -Path $downloadDir
  71. }
  72. }
  73. }