Created
February 14, 2021 06:43
-
-
Save old-horizon/3a939c0d530370e3b7d568a352f58adb to your computer and use it in GitHub Desktop.
Vagrantfile to create IE11 Selenium Grid Node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANT_BOX = ENV['VAGRANT_BOX'] | |
SELENIUM_HUB_IP = ENV['SELENIUM_HUB_IP'] | |
SELENIUM_NODE_IP = ENV['SELENIUM_NODE_IP'] | |
SELENIUM_NODE_PORT = ENV['SELENIUM_NODE_PORT'].to_i | |
Vagrant.configure('2') do |config| | |
config.vm.box = VAGRANT_BOX | |
config.vm.network :forwarded_port, guest: 5555, host: SELENIUM_NODE_PORT | |
config.vm.guest = :windows | |
config.vm.communicator = :winrm | |
config.winrm.username = 'IEUser' | |
config.winrm.password = 'Passw0rd!' | |
config.vm.provider :virtualbox do |vb| | |
vb.memory = '2048' | |
vb.linked_clone = true | |
vb.customize [ | |
'modifyvm', :id, | |
'--vram', '256', | |
'--accelerate2dvideo', 'on', | |
'--accelerate3d', 'on', | |
'--graphicscontroller', 'vboxsvga' | |
] | |
end | |
config.vm.provision :shell, reboot: true, inline: <<-"SHELL" | |
function Renew-ItemProperty($Path, $Name, $PropertyType, $Value) { | |
if (!(Test-Path $Path)) { | |
New-Item -Path $Path -Force | |
New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force | |
} else { | |
New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force | |
} | |
} | |
############################## | |
# Windows # | |
############################## | |
# Disable Auto Update | |
Renew-ItemProperty -Path 'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\WindowsUpdate\\AU' -Name NoAutoUpdate -PropertyType DWord -Value 1 | |
# Disable Windows Defender | |
Renew-ItemProperty -Path 'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows Defender' -Name DisableAntiSpyware -PropertyType DWord -Value 1 | |
Remove-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run' -Name SecurityHealth -ErrorAction SilentlyContinue | |
# Disable Notification Center | |
Renew-ItemProperty -Path 'HKCU:\\SOFTWARE\\Policies\\Microsoft\\Windows\\Explorer' -Name DisableNotificationCenter -PropertyType DWord -Value 1 | |
Renew-ItemProperty -Path 'HKCU:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\PushNotifications' -Name ToastEnabled -PropertyType DWord -Value 0 | |
# Disable Monitor Timeout | |
powercfg /change monitor-timeout-ac 0 | |
powercfg /change monitor-timeout-dc 0 | |
# Enable Auto Logon | |
Renew-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon' -Name AutoAdminLogon -PropertyType DWord -Value 1 | |
Renew-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon' -Name DefaultUserName -PropertyType String -Value IEUser | |
Renew-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon' -Name DefaultPassword -PropertyType String -Value Passw0rd! | |
# Enable Japanese IME | |
Set-WinUserLanguageList ja-JP -Force | |
# Change Timezone | |
Set-Timezone -Name 'Tokyo Standard Time' | |
# Use Japanese Keyboard Layout | |
Renew-ItemProperty -Path 'HKLM:\\SYSTEM\\CurrentControlSet\\Services\\i8042prt\\Parameters' -Name 'LayerDriver JPN' -PropertyType String -Value kbd106.dll | |
Renew-ItemProperty -Path 'HKLM:\\SYSTEM\\CurrentControlSet\\Services\\i8042prt\\Parameters' -Name OverrideKeyboardIdentifier -PropertyType String -Value PCAT_106KEY | |
Renew-ItemProperty -Path 'HKLM:\\SYSTEM\\CurrentControlSet\\Services\\i8042prt\\Parameters' -Name OverrideKeyboardSubtype -PropertyType DWord -Value 2 | |
# Disable BgInfo | |
Remove-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run' -Name bginfo -ErrorAction SilentlyContinue | |
# Set Wallpaper | |
Renew-ItemProperty -Path 'HKCU:\\Control Panel\\Desktop' -Name Wallpaper -PropertyType String -Value C:\\Windows\\Web\\Wallpaper\\Windows\\img0.jpg | |
Renew-ItemProperty -Path 'HKCU:\\Control Panel\\Desktop' -Name WallpaperStyle -PropertyType String -Value 10 | |
Renew-ItemProperty -Path 'HKCU:\\Control Panel\\Desktop' -Name TileWallpaper -PropertyType String -Value 0 | |
############################## | |
# Internet Explorer # | |
############################## | |
# Disable First Run Customize | |
Renew-ItemProperty -Path 'HKCU:\\Software\\Microsoft\\Internet Explorer\\Main' -Name DisableFirstRunCustomize -PropertyType DWord -Value 1 | |
# Disable Warn On Zone Crossing | |
Renew-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings' -Name WarnOnZoneCrossing -Type DWord -Value 0 | |
# Enable Protected Mode | |
Renew-ItemProperty -Path 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\1' -Name 2500 -PropertyType DWord -Value 0 | |
Renew-ItemProperty -Path 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\2' -Name 2500 -PropertyType DWord -Value 0 | |
Renew-ItemProperty -Path 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3' -Name 2500 -PropertyType DWord -Value 0 | |
Renew-ItemProperty -Path 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\4' -Name 2500 -PropertyType DWord -Value 0 | |
# Disable Enhanced Protected Mode | |
Renew-ItemProperty -Path 'HKCU:\\Software\\Microsoft\\Internet Explorer\\Main' -Name Isolation -PropertyType String -Value PMIL | |
# For Internet Explorer Driver | |
Renew-ItemProperty -Path 'HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BFCACHE' -Name iexplore.exe -PropertyType DWord -Value 0 | |
Renew-ItemProperty -Path 'HKCU:\\Software\\Microsoft\\Internet Explorer\\Main' -Name TabProcGrowth -PropertyType DWord -Value 0 | |
############################## | |
# Chocolatey # | |
############################## | |
# Install | |
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | |
############################## | |
# Virtualbox Guest Additions # | |
############################## | |
# Install | |
choco install -y virtualbox-guest-additions-guest.install | |
############################## | |
# Selenium # | |
############################## | |
# Install Internet Explorer Driver and JRE | |
choco install -y selenium-ie-driver openjdk11jre | |
# Generate Capabilities JSON | |
$capabilitiesJson = 'C:\\tools\\selenium\\capabilities.json' | |
ConvertTo-Json @( | |
@{ | |
browserName = 'internet explorer' | |
maxInstances = 1 | |
version = 'autoversion' | |
seleniumProtocol = 'WebDriver' | |
} | |
) | Set-Content $capabilitiesJson -Encoding Ascii | |
# Install Selenium Node | |
choco install -y selenium --params \"'/role:node /hub:http://#{SELENIUM_HUB_IP}:4444 /capabilitiesJson:$capabilitiesJson'\" | |
# Modify Startup Script | |
$scriptPath = 'C:\\tools\\selenium\\node.cmd' | |
(Get-Content $scriptPath) -replace '(^.*nodeconfig\\.json\").*$', '$1 -remoteHost http://#{SELENIUM_NODE_IP}:#{SELENIUM_NODE_PORT}' | Set-Content $scriptPath -Encoding Ascii | |
# Run At Startup | |
Renew-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run' -Name Selenium -PropertyType String -Value \"cmd /c start `\"Selenium`\" /min `\"$scriptPath`\"\" | |
SHELL | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment