Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to set up windows machine for selenium and jenkins
# Setting up internet explorer machine with selenium
Download the machine with appropriate windows and IE from microsoft
Boot it up with GUI
Disable UAC and firewall - its an isolated machine that noone will access anyway(and if they do, theres really nothing there), so why bother
# Copssh
Download and install copssh. This tool will easily allow you to ssh into the machine
in Copssh control panel open the "Users" tab and add the current user to there as(eg. "ie10win7\ieuser") and some public key to that you use for logging in
# Java
Download and install java and add java to windows PATH
# Selenium
Download selenium stand alone server and IEDriver
Put the files to C:\selenium
Add C:\selenium to windows PATH
Create a .bat file to the selenium folder. Inside the bat file, paste this:
java.exe -jar C:\selenium\selenium-server-standalone-2.42.2.jar -browser "browserName=internet explorer,maxinstance=1,platform=WINDOWS""C:/selenium/IEDriverServer.exe" -timeout 120 -browserTimeout 120
# Set up jenkins slave
Create a JNLP slave in CI and set up a scheduled slave agent on windows boot
To make it comfortable, i suggest keeping the slave.jar in C:\selenium. Then Everything regarding selenium is in 1 folder
# Setting up Internet Explorer
Open IE and then choose "Dont use the recommended settings". Open internet options and make sure that
a) Set the Protected Mode settings for each zone to be the same value. The value can be on or off(RECOMMENDED), as long as it is the same for every zone. To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab.
b) Pop ups are blocked
c) On IE 10 and higher Enhanced Protected Mode must be disabled
# Download and install ultravnc
You should always use VNC, when possible, to log in to a windows machine. If you use RDP, then once you close the session, it locks it and you cant see any screenshots. Also, windows lose their focus. We will also create local vnc session, to keep user session open.
Make sure you install the server as service and to log on at the startup
The VNC and view-only passwords can be the same, e.g. vagrant
Try to connect with the ultraVNC viewer to ```localhost``` make sure that the server works. Then try to connect from another computer. You may need to restart the service, or in a worse case, virtual machine for it to work.
You should now set up a local vnc viewer connection, so when tests run, the windows will always think there is an actual graphical session going on and doesnt time out Internet Explorer for whatever reason(Maybe because it thinks its a background process?)
Donwload nircmd and extract it to C:\selenium
Create a ```vnc.bat``` file to C:\selenium and copy-paste this inside it(chaning password to whatever you chose):
ping -n 9 >nul # Wait for vnc service to become online
start "" "C:\Program Files\uvnc bvba\UltraVNC\vncviewer.exe" -connect localhost -password vagrant
ping -n 5 >nul # Wait for vnc viewer to load itself
cd C:\selenium
nircmd.exe sendkeypress rwin+D # Minimize all windows
Now create a shortcut of this script, change the shortcut properties to it would start minimized and put it to the windows startup folder. This makes sure the script is run every time windows starts.
# Make it into vagrant box
Shutdown the machine and go to the linux machine where vagrant is installed.
List all the running vms you have and find you windows machine name
vboxmanage list vms
Run the command(
vagrant package --base TheWindowsMachineName --output
# Set up a new instance of the machine
Go to some folder you would like the new machine and run the following:
vagrant init myBoxName
Change the vagrant file to include the following:
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| = "win7ie10" :public_network, ip: "", bride: 'th0'
config.ssh.username = "ieuser"
config.vm.provider "virtualbox" do |v|
v.memory = 1024
Run the command
```vagrant up```
You can now get into the machine with the command
```vagrant ssh```
Then you can get the machine ip, to log in with remote desktop using the command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.