Repository: conceptsandtraining/modernie_selenium
Branch: master
Commit: 159281ac82e0
Files: 16
Total size: 32.6 KB
Directory structure:
gitextract_xfvv82cn/
├── .gitignore
├── LICENSE
├── Makefile
├── README.md
├── Tools/
│ ├── ie11_win32.reg
│ ├── ie_disablecache.reg
│ ├── ie_protectedmode.reg
│ └── selenium_conf/
│ ├── WIN7/
│ │ ├── IE10/
│ │ │ └── config.json
│ │ ├── IE11/
│ │ │ └── config.json
│ │ ├── IE8/
│ │ │ └── config.json
│ │ └── IE9/
│ │ └── config.json
│ └── selenium.bat
├── config.sh
├── mkvm.sh
├── mkvm_cron.sh
└── mkvm_cronjob
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
VMs/**/*.*
Tools/*.exe
Tools/*.iso
Tools/*.msi
Tools/*.bat
Tools/hosts
!Tools/jre-windows-i586.exe
Tools/selenium_conf/*.exe
Tools/selenium_conf/*.zip
Tools/selenium_conf/*.jar
*log
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2014 Denis Witt
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: Makefile
================================================
all: fetch fetch_vms
fetch: selenium-server deuac IEDriver
fetch_vms: IE11-Win7 IE10-Win7 IE9-Win7 IE8-Win7
IE11-Win7:
curl -O -L "https://az412801.vo.msecnd.net/vhd/VMBuild_20141027/VirtualBox/IE11/Windows/IE11.Win7.For.Windows.VirtualBox.zip"
unzip IE11.Win7.For.Windows.VirtualBox.zip
mkdir VMs || true
mv IE11\ -\ Win7.ova VMs
rm IE11.Win7.For.Windows.VirtualBox.zip
IE10-Win7:
curl -O -L "https://az412801.vo.msecnd.net/vhd/VMBuild_20141027/VirtualBox/IE10/Windows/IE10.Win7.For.Windows.VirtualBox.zip"
unzip IE10.Win7.For.Windows.VirtualBox.zip
mkdir VMs || true
mv IE10\ -\ Win7.ova VMs
rm IE10.Win7.For.Windows.VirtualBox.zip
IE9-Win7:
curl -O -L "https://az412801.vo.msecnd.net/vhd/VMBuild_20141027/VirtualBox/IE9/Windows/IE9.Win7.For.Windows.VirtualBox.zip"
unzip IE9.Win7.For.Windows.VirtualBox.zip
mkdir VMs || true
mv IE9\ -\ Win7.ova VMs
rm IE9.Win7.For.Windows.VirtualBox.zip
IE8-Win7:
curl -O -L "https://az412801.vo.msecnd.net/vhd/VMBuild_20141027/VirtualBox/IE8/Windows/IE8.Win7.For.Windows.VirtualBox.zip"
unzip IE8.Win7.For.Windows.VirtualBox.zip
mkdir VMs || true
mv IE8\ -\ Win7.ova VMs
rm IE8.Win7.For.Windows.VirtualBox.zip
selenium-server:
curl -o Tools/selenium_conf/selenium-server-standalone.jar -L http://selenium-release.storage.googleapis.com/2.44/selenium-server-standalone-2.44.0.jar
deuac:
curl -o Tools/deuac.iso -L https://github.com/tka/SeleniumBox/blob/master/deuac.iso?raw=true
IEDriver:
curl -o Tools/selenium_conf/IEDriverServer.zip -L http://selenium-release.storage.googleapis.com/2.44/IEDriverServer_Win32_2.44.0.zip
#curl -o Tools/selenium_conf/IEDriverServer.zip -L http://selenium-release.storage.googleapis.com/2.44/IEDriverServer_x64_2.44.0.zip
cd Tools/selenium_conf && unzip IEDriverServer.zip
# Not using this as we are using vm only for IE
chromedriver:
curl -o Tools/selenium_conf/chromedriver.zip -L http://chromedriver.storage.googleapis.com/2.15/chromedriver_win32.zip
cd Tools/selenium_conf && unzip chromedriver.zip
# Commenting command line jre download as this is broken, oracle has include some sort of hash in download url, need to fix this
#Tools/jre-windows-i586.exe:
# curl -j -o Tools/jre-windows-i586.exe -L -O -H "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u151-b12/jre-8u151-windows-i586.exe
# Not using this as we are using vm only for IE
firefox:
curl -o Tools/firefox.exe -L "https://download.mozilla.org/?product=firefox-34.0.5-SSL&os=win&lang=en-GB"
# Not using this as we are using vm only for IE
chrome:
curl -o Tools/chrome.exe -L "https://dl.google.com/update2/installers/ChromeStandaloneSetup.exe"
================================================
FILE: README.md
================================================
modernie_selenium
=================
Manage modern.ie VirtualBox-Appliances with Selenium-Support
This script allows to delete and create virtual Windows-Machines using Images from http://www.modern.ie for automating Browser-Testing with Selenium.
As the modern.ie-Machines refuses to run more than 30-90 Days (at least for more than an hour) we remove the machines on a regular basis and recreate the original Appliance with all changes needed to run Selenium.
Prerequisites
=================
* VirtualBox (tested with 5.0.30)
* VirtualBox Extension Pack
* Selenium-Hub
What it does
=================
* Import modern.ie VM images to VirtualBox
* Configure VM Network-Settings
* Configure VM RDP-Port-Setting (VRDE)
* Configure VM Clipboard behaviour
* Disable UAC
* Disable Windows-Firewall
* Rename the VM (Hostname)
* Update windows hosts file with hub ip
* Configures IE Protected-Mode to work with Selenium
* Disables IE Cache
* Install Java
* Install Selenium node and register to hub
What it doesn't do
==================
* Set up VirtualBox
Getting started
===============
* Run make all
* Run ```mkvm.sh /path/to/your/appliance/foobar.ova```.
Fetching the Appliances
=======================
Get all VM images using this command:
```
make fetch_vms
```
Configure
=========
Adjust ```config.sh``` to your needs. See below for details.
If you use the Makefile to get the binary files then you shouldn't have to alter the config script.
By default the Script assumes that your VirtualBox-Machines are placed in ```VMs/``` and that the script is run by the User the script is run as. All supplemental files should be placed in ```Tools/``` but you can configure different paths.
To do so simply edit ```config.sh```:
```
java_exe="jre-windows-i586.exe"
```
Filename of your Java-Installer.
```
selenium_jar="selenium-server-standalone.jar"
```
Filename of your Selenium-Server.
```
nic_bridge="eth0"
```
Name of your Network-Interface to use as bridge for your VM.
```
vm_path="VMs/"
```
Path where to put your VMs.
```
vm_mem="768"
```
Amount of memory (RAM) for Windows Vista, 7 and 8.x VMs in MB.
```
vm_mem_xp="512"
```
Amount of memory (RAM) for Windows XP VMs in MB.
```
deuac_iso="Tools/deuac.iso"
```
Path and filename for deuac.iso (a bootable CD-Image to disable UAC so we can install Java without Problems).
```
tools_path="Tools/"
```
Path to ```java_exe```, ```firefox_exe``` and ```chrome_exe``` (Location of Installers on VM-Host).
```
selenium_path="Tools/selenium_conf/"
```
Path to your Selenium-Config-Files. It's important that you keep the folder structure below this point, otherwise the config will not be copied to the VMs (or the wrong Config goes to the wrong Machines).
```
ie_cache_reg="Tools/ie_disablecache.reg"
```
Path and filename to ```ie_disablecache.reg``` (Disables Internet Explorer Cache).
```
ie_protectedmode_reg="Tools/ie_protectedmode.reg"
```
Path and filename to ```ie_protectedmode.reg``` (Enables Protected Mode for all IE Security Zones).
```
log_path=""
```
Path to the (temporary) Logfile.
```
vbox_user="${USER}"
```
Username of VirtualBox-User.
```
mailto="root@example.com"
```
E-Mail-Adress to send logfile to.
```
create_snapshot=False
```
If ```True``` a snapshot will be created after all changes have been made.
Selenium Config / Hub Hostname
==============================
Hub should be running on host OS, as scripts fetch the ip of host os and put that into hosts file of windows vm. Need to change the script to fetch the ip of docker hub
Usage
=====
Run below command:
```
make fetch
```
Get specific VM image[Check options in make file]:
```
make IE11-Win7
```
To import the IE11-Win7 Appliance simply run:
```
mkvm.sh VMs/IE11\ -\ Win7.ova
```
If you already have an IE11-Win7-Instance - and want to recreate it - run:
```
mkvm.sh VMs/IE11\ -\ Win7.ova --delete "IE11 - Win7"
```
TODO
==============
* Network Confguration
* Jre installation link broken as Oracle has included has in the url[Fix: JRE exe is on Tools directory]
* Windows silent activation
* Need to change the script to fetch the ip of docker hub and update in windows hosts file
================================================
FILE: Tools/ie11_win32.reg
================================================
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BFCACHE]
"iexplore.exe"=dword:00000000
================================================
FILE: Tools/ie_disablecache.reg
================================================
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
“Start Page”=”about:blank”
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\CACHE]
"Persistent"=dword:00000000
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Privacy]
"ClearBrowsingHistoryOnExit"=dword:00000001
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"SyncMode5"=dword:00000003
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Url History]
"DaysToKeep"=dword:00000000
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache\Content]
"CacheLimit"=dword:00002000
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Content]
"CacheLimit"=dword:00002000
================================================
FILE: Tools/ie_protectedmode.reg
================================================
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\0]
"2500"=dword:00000000
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1]
"2500"=dword:00000000
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2]
"2500"=dword:00000000
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3]
"2500"=dword:00000000
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\4]
"2500"=dword:00000000
================================================
FILE: Tools/selenium_conf/WIN7/IE10/config.json
================================================
{
"configuration": {
"port": 5555,
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": "hubhost"
},
"capabilities": [
{
"platform": "WINDOWS",
"browserName": "internet explorer",
"version": 10,
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
]
}
================================================
FILE: Tools/selenium_conf/WIN7/IE11/config.json
================================================
{
"configuration": {
"port": 5555,
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": "hubhost"
},
"capabilities": [
{
"platform": "WINDOWS",
"browserName": "internet explorer",
"version": 11,
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
]
}
================================================
FILE: Tools/selenium_conf/WIN7/IE8/config.json
================================================
{
"configuration": {
"port": 5555,
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": "hubhost"
},
"capabilities": [
{
"platform": "WINDOWS",
"browserName": "internet explorer",
"version": 8,
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
]
}
================================================
FILE: Tools/selenium_conf/WIN7/IE9/config.json
================================================
{
"configuration": {
"port": 5555,
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": "hubhost"
},
"capabilities": [
{
"platform": "WINDOWS",
"browserName": "internet explorer",
"version": 9,
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
]
}
================================================
FILE: Tools/selenium_conf/selenium.bat
================================================
"C:\Program Files\Java\jre1.8.0_151\bin\java.exe" -jar c:\selenium\selenium-server-standalone.jar -role node -nodeConfig c:\selenium\config.json
================================================
FILE: config.sh
================================================
# Config; See readme for details.
java_exe="jre-windows-i586.exe"
firefox_exe="firefox.exe"
chrome_exe="chrome.exe"
selenium_jar="selenium-server-standalone.jar"
if [ $(uname) == "Darwin" ]
then
# This makes sense on a mac
nic_bridge="en0"
else
# This works on Ubuntu
nic_bridge="eth0"
fi
vm_path="VMs/"
vm_mem="768"
vm_mem_xp="512"
deuac_iso="deuac.iso"
tools_path="$(pwd)/Tools/"
selenium_path="$(pwd)/Tools/selenium_conf/"
ie_cache_reg="ie_disablecache.reg"
ie_protectedmode_reg="ie_protectedmode.reg"
log_path=""
vbox_user="${USER}"
mailto="root"
create_snapshot=False
================================================
FILE: mkvm.sh
================================================
#!/bin/bash
# Debug
#set -x
#set -e
source config.sh
# Basic-Checks.
if [ "${1}" = "--help" ]; then
echo "Usage: $0 path_to_ova [--delete VM-Name/UID]"
exit 0
fi
if [ -z "${1}" ]; then
echo "Appliance-Path is missing..."
exit 1
fi
if [ ! -f "${1}" ]; then
echo "Appliance ${1} not found..."
exit 1
fi
if [ ! $(which VBoxManage) ]; then
echo "VBoxManage not found..."
exit 1
fi
if [ "${USER}" != "${vbox_user}" ]; then
echo "This script must be run by user \'${vbox_user}\'..."
exit 1
fi
# Init; Do not change.
appliance=${1}
remove_vm=${3}
vm_name=False
vm_pretty_name=False
fatal=False
error=False
warning=False
copyto() {
# $1 = filename, $2 = source directory, $3 destination directory
if [ ! -f "${2}${1}" ]
then
echo "Local file '${2}${1}' doesn't exist"
fi
execute "VBoxManage guestcontrol \"${vm_name}\" copyto --target-directory \"${3}${1}\" \"${2}${1}\" --username 'IEUser' --password 'Passw0rd!'"
}
# Loop VBoxManage guestcontrol commands as they are unreliable.
execute() {
counter=0
while [ $counter -lt 3 ]; do
echo "Running $@"
bash -c "$@"
if [ "$?" = "0" ]; then
guestcontrol_error=0
break
else
guestcontrol_error=1
fi
let counter=counter+1
sleep 10
done
if [ "$guestcontrol_error" = "0" ]; then
return 0
else
chk skip 1 "Error running $@"
fi
}
# Write Logfile and STDOUT.
log() {
echo ${1} | tee -a "${log_path}${vm_pretty_name}.log"
}
# Error-Handling.
chk() {
if [ "${2}" != "0" ]; then
if [ "${1}" = "fatal" ]; then
log "[FATAL] ${3}"
fatal=True
sendmessage
exit ${2}
fi
if [ "${1}" = "skip" ]; then
log "[WARNING] ${3}"
warning=True
fi
if [ "${1}" = "error" ]; then
log "[ERROR] ${3}"
error=True
fi
else
log "[OK]"
fi
}
# Send Status-Mail.
sendmessage() {
if [ ! -z ${mailto} ]; then
subject_prefix="SUCCESS"
if [ "${warning}" = "True" ]; then
subject_prefix="WARNING"
fi
if [ "${error}" = "True" ]; then
subject_prefix="ERROR"
fi
if [ -f "${log_path}False.log" ]; then
cat "${log_path}False.log" "${log_path}${vm_pretty_name}.log" > /tmp/${vm_pretty_name}.log
cat "/tmp/${vm_pretty_name}.log" | mail -s "${subject_prefix}: ${vm_name}" ${mailto}
rm "${log_path}${vm_pretty_name}.log"
rm "${log_path}False.log"
else
cat "${log_path}${vm_pretty_name}.log" | mail -s "${subject_prefix}: ${vm_name}" ${mailto}
rm "${log_path}${vm_pretty_name}.log"
fi
fi
}
# Get VM OS-Type.
execute_os_specific() {
case "${vm_os_type}" in
WindowsXP)
${1}_xp
;;
WindowsVista)
${1}_wv
;;
Windows7)
${1}_w7
;;
Windows8*)
${1}_w8
;;
*)
chk skip 1 "Unexpected OS-Type, skipping ${1}..."
;;
esac
}
# Check if the VM is still running.
check_shutdown() {
counter=0
echo -n "Waiting for shutdown"
while $(VBoxManage showvminfo "${vm_name}" | grep -q 'running'); do
echo -n "."
sleep 1
let counter=counter+1
if [ ${counter} -ge 120 ]; then
chk skip 1 "Unable to shutdown/restart..."
break
fi
done
echo ""
waiting 5
}
# Print some dots.
waiting() {
counter=0
echo -n "Waiting ${1} seconds"
while [ ${counter} -lt ${1} ]; do
echo -n "."
let counter=counter+1
sleep 1
done
echo ""
}
# Get informations about the given Appliance (Name, OS-Type, IE-Version)
get_vm_info() {
vm_info=$(VBoxManage import "${appliance}" -n)
chk fatal $? "Error getting Appliance Info"
vm_name=$(echo "${vm_info}" | grep "Suggested VM name" | awk -F'"' '{print $2}')
vm_pretty_name=$(echo "${vm_info}" | grep "Suggested VM name" | awk -F'"' '{print $2}' | sed 's/_/-/g' | sed 's/ //g' | sed 's/\.//g')
vm_os_type=$(echo "${vm_info}" | grep 'Suggested OS type' | awk -F'"' '{print $2}')
vm_ie=$(echo "${vm_name}" | awk -F' -' '{print $1}')
}
#Internal: Helper-Functions to install the Appliance (called by import_vm)
ex_import_vm_xp() {
VBoxManage import "${appliance}" --vsys 0 --memory ${vm_mem_xp}
chk fatal $? "Could not import VM"
}
ex_import_vm_w7() {
VBoxManage import "${appliance}" --vsys 0 --memory ${vm_mem}
chk fatal $? "Could not import VM"
}
ex_import_vm_wv() {
ex_import_vm_w7
}
ex_import_vm_w8() {
ex_import_vm_w7
}
# Import the given Appliance-File; OS-Specific
import_vm() {
log "Importing ${appliance} as ${vm_name}..."
execute_os_specific ex_import_vm
}
# Set VM Network-Config.
set_network_config() {
log "Setting network bridge ${nic_bridge}..."
execute "VBoxManage modifyvm \"${vm_name}\" --nic1 bridged --bridgeadapter1 \"${nic_bridge}\""
chk error $? "Could not set Bridge"
}
# Find and set free Port for RDP-Connection.
set_rdp_config() {
log "Setting VRDE-Port ${vrdeport}..."
vrdeports=$(find "${vm_path}" -name *.vbox -print0 | xargs -0 grep "TCP/Ports" | awk -F'"' '{print $4}' | sort)
for ((i=9000;i<=10000;i++)); do
echo ${vrdeports} | grep -q ${i}
if [[ $? -ne 0 ]]; then
vrdeport=$i
break
fi
done
if [ -z "${vrdeport}" ]; then
vrdeport="9000"
fi
if [[ ${vrdeport} < 9000 ]]; then
vrdeport="9000"
fi
if [ "${vrdeport}" = "10000" ]; then
chk skip $? "Could not find free VRDE-Port"
else
execute "VBoxManage modifyvm \"${vm_name}\" --vrde on --vrdeport \"${vrdeport}\""
chk error $? "Could not set VRDE-Port"
fi
}
# Internal: Helper-Functions to disable UAC (called by disable_uac)
ex_disable_uac_w7() {
log "Mounting Disk..."
VBoxManage storageattach "${vm_name}" --storagectl "IDE" --port 1 --device 0 --type dvddrive --medium "${tools_path}${deuac_iso}"
chk fatal $? "Could not mount ${tools_path}${deuac_iso}"
log "Disabling UAC..."
VBoxManage startvm "${vm_name}" --type headless
chk fatal $? "Could not start VM to disable UAC"
waiting 60
check_shutdown
log "Removing Disk..."
VBoxManage storageattach "${vm_name}" --storagectl "IDE" --port 1 --device 0 --type dvddrive --medium none
chk fatal $? "Could not unmount ${deuac_iso}"
}
ex_disable_uac_wv() {
ex_disable_uac_w7
}
ex_disable_uac_w8() {
ex_disable_uac_w7
}
ex_disable_uac_xp() {
return 1
}
# Disable UAC; Required to install Java successfully later; OS-Specific
disable_uac() {
execute_os_specific ex_disable_uac
}
# Start the VM; Wait some seconds afterwards to give the VM time to start up completely.
start_vm() {
log "Starting VM ${vm_name}..."
VBoxManage startvm "${vm_name}" --type headless
chk fatal $? "Could not start VM"
waiting 60
}
# Internal: Helper-Functions to disable the Windows Firewall (called by disable_firewall)
ex_disable_firewall_xp() {
log "Disabling Windows XP Firewall..."
execute "VBoxManage guestcontrol \"${vm_name}\" run --exe 'C:/windows/system32/netsh.exe' --username 'IEUser' --password 'Passw0rd!' -- netsh/arg0 firewall set opmode mode=DISABLE"
chk error $? "Could not disable Firewall"
}
ex_disable_firewall_w7() {
log "Disabling Windows Firewall..."
execute "VBoxManage guestcontrol \"${vm_name}\" run --exe 'C:/windows/system32/netsh.exe' --username 'IEUser' --password 'Passw0rd!' -- netsh/arg0 advfirewall set allprofiles state off"
chk error $? "Could not disable Firewall"
}
ex_disable_firewall_wv() {
ex_disable_firewall_w7
}
ex_disable_firewall_w8() {
ex_disable_firewall_w7
}
# Disable the Windows Firewall; OS-Specific
disable_firewall() {
execute_os_specific ex_disable_firewall
}
# Create C:\Temp\; Most Functions who copy files to the VM are relying on this folder and will fail is he doesn't exists.
create_temp_path() {
vm_temp="C:/Temp/"
log "Creating ${vm_temp}..."
execute "VBoxManage guestcontrol \"${vm_name}\" createdirectory \"${vm_temp}\" --username 'IEUser' --password 'Passw0rd!'"
chk fatal $? "Could not create ${vm_temp}"
}
# Apply registry changes to configure Internet Explorer settings (Protected-Mode, Cache)
set_ie_config() {
log "Apply IE Protected-Mode Settings..."
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${ie_protectedmode_reg}\" "${vm_temp}" --username 'IEUser' --password 'Passw0rd!'"
copyto "${ie_protectedmode_reg}" "$tools_path" "$vm_temp"
execute "VBoxManage guestcontrol \"${vm_name}\" run --exe 'C:\\Windows\\Regedit.exe' --username 'IEUser' --password 'Passw0rd!' -- Regedit/arg0 /s '${vm_temp}ie_protectedmode.reg'"
chk error $? "Could not apply IE Protected-Mode-Settings"
log "Disabling IE-Cache..."
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${ie_cache_reg}\" "${vm_temp}" --username 'IEUser' --password 'Passw0rd!'"
copyto ie_disablecache.reg "${tools_path}" "${vm_temp}"
execute "VBoxManage guestcontrol \"${vm_name}\" run --exe 'C:\\Windows\\Regedit.exe' --username 'IEUser' --password 'Passw0rd!' -- Regedit/arg0 /s '${vm_temp}ie_disablecache.reg'"
chk error $? "Could not disable IE-Cache"
}
# Install Java (required by Selenium); We don't use --wait-exit as it may cause trouble with XP-VMs, instead we just wait some time to ensure the Java-Installer can finish.
install_java() {
log "Installing Java..."
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${tools_path}${java_exe}\" "${vm_temp}" --username 'IEUser' --password 'Passw0rd!'"
copyto "${java_exe}" "${tools_path}" "${vm_temp}"
execute "VBoxManage guestcontrol \"${vm_name}\" run --exe \"${vm_temp}${java_exe}\" --username 'IEUser' --password 'Passw0rd!' -- ${java_exe}/args0 /s"
chk error $? "Could not install Java"
waiting 120
}
# Install Firefox.
install_firefox() {
log "Installing Firefox..."
copyto "${firefox_exe}" "${tools_path}" "${vm_temp}"
execute "VBoxManage guestcontrol \"${vm_name}\" run --exe \"${vm_temp}${firefox_exe}\" --username 'IEUser' --password 'Passw0rd!' -- ${firefox_exe}/args0 /S"
chk error $? "Could not install Firefox"
waiting 120
}
# Install Chrome-Driver for Selenium
install_chrome_driver() {
log "Installing Chrome Driver..."
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${selenium_path}chromedriver.exe\" C:/Windows/system32/ --username 'IEUser' --password 'Passw0rd!'"
copyto chromedriver.exe "${selenium_path}" "C:/Windows/system32/"
chk error $? "Could not install Chrome Driver"
waiting 5
}
# Install Chrome.
install_chrome() {
log "Installing Chrome..."
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${tools_path}${chrome_exe}\" "${vm_temp}" --username 'IEUser' --password 'Passw0rd!'"
copyto "${chrome_exe}" "${tools_path}" "${vm_temp}"
execute "VBoxManage guestcontrol \"${vm_name}\" run --exe 'C:/Windows/System32/msiexec.exe' --username 'IEUser' --password 'Passw0rd!' -- msiexec/args0 /qn /i \"${vm_temp}${chrome_exe}\""
chk error $? "Could not install Chrome"
waiting 120
install_chrome_driver
}
# Internal: Helper-Functions to Install Selenium (called by install_selenium)
start_selenium_xp() {
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${selenium_path}selenium.bat\" 'C:/Documents and Settings/All Users/Start Menu/Programs/Startup/' --username 'IEUser' --password 'Passw0rd!'"
copyto "selenium.bat" "${selenium_path}" 'C:/Documents and Settings/All Users/Start Menu/Programs/Startup/'
chk error $? "Could not copy Selenium-Startup-File"
}
start_selenium_w7() {
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${selenium_path}selenium.bat\" 'C:/ProgramData/Microsoft/Windows/Start Menu/Programs/Startup/' --username 'IEUser' --password 'Passw0rd!'"
copyto "selenium.bat" "${selenium_path}" 'C:/ProgramData/Microsoft/Windows/Start Menu/Programs/Startup/'
chk error $? "Could not copy Selenium-Startup-File"
}
start_selenium_wv() {
start_selenium_w7
}
start_selenium_w8() {
start_selenium_w7
}
config_selenium_xp() {
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${selenium_path}XP/${vm_ie}/config.json\" C:/selenium/ --username 'IEUser' --password 'Passw0rd!'"
copyto config.json "${selenium_path}XP/${vm_ie}/" "C:/selenium/"
chk error $? "Could not copy Selenium-Config"
}
config_selenium_w7() {
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${selenium_path}WIN7/${vm_ie}/config.json\" C:/selenium/ --username 'IEUser' --password 'Passw0rd!'"
copyto config.json "${selenium_path}WIN7/${vm_ie}/" "C:/selenium/"
chk error $? "Could not copy Selenium-Config"
}
config_selenium_wv() {
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${selenium_path}VISTA/${vm_ie}/config.json\" C:/selenium/ --username 'IEUser' --password 'Passw0rd!'"
copyto config.json "${selenium_path}VISTA/${vm_ie}/" "C:/selenium/"
chk error $? "Could not copy Selenium-Config"
}
config_selenium_w8() {
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${selenium_path}WIN8/${vm_ie}/config.json\" C:/selenium/ --username 'IEUser' --password 'Passw0rd!'"
copyto config.json "${selenium_path}WIN8/${vm_ie}/" "C:/selenium/"
chk error $? "Could not copy Selenium-Config"
}
ie11_driver_reg() {
if [ "${vm_ie}" = "IE11" ]; then
log "Copy ie11_win32.reg..."
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${tools_path}ie11_win32.reg\" "${vm_temp}" --username 'IEUser' --password 'Passw0rd!'"
copyto ie11_win32.reg "${tools_path}" "${vm_temp}"
chk skip $? "Could not copy ie11_win32.reg"
log "Setting ie11_win32.reg..."
execute "VBoxManage guestcontrol \"${vm_name}\" run --exe 'C:\\Windows\\Regedit.exe' --username 'IEUser' --password 'Passw0rd!' -- Regedit/arg0 /s '${vm_temp}ie11_win32.reg'"
chk skip $? "Could not set ie11_win32.reg"
fi
}
# Install Selenium
install_selenium() {
log "Creating C:/selenium/..."
execute "VBoxManage guestcontrol \"${vm_name}\" createdirectory C:/selenium/ --username 'IEUser' --password 'Passw0rd!'"
chk fatal $? "Could not create C:/Selenium/"
log "Installing Selenium..."
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${selenium_path}${selenium_jar}\" C:/selenium/ --username 'IEUser' --password 'Passw0rd!'"
copyto "${selenium_jar}" "${selenium_path}" "C:/selenium/"
chk error $? "Could not install Selenium"
log "Installing IEDriverServer..."
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto \"${selenium_path}IEDriverServer.exe\" C:/Windows/system32/ --username 'IEUser' --password 'Passw0rd!'"
copyto "IEDriverServer.exe" "${selenium_path}" "C:/Windows/system32/"
chk error $? "Could not install IEDriverServer.exe"
log "Configure Selenium..."
execute_os_specific config_selenium
log "Prepare Selenium-Autostart..."
execute_os_specific start_selenium
ie11_driver_reg
}
# Create a Snapshot; Disabled by default.
snapshot_vm() {
log "Creating Snapshot ${1}..."
VBoxManage snapshot "${vm_name}" take "${1}"
chk skip $? "Could not create Snapshot ${1}"
}
# Reboot the VM; Ensure to wait some time after sending the reboot-Command so that the machine can start up before other actions will applied.
# shutdown.exe is used because VBox ACPI-Functions are sometimes unreliable with XP-VMs.
reboot_vm() {
log "Rebooting..."
execute "VBoxManage guestcontrol \"${vm_name}\" run --exe C:/Windows/system32/shutdown.exe --username 'IEUser' --password 'Passw0rd!' -- shutdown/args0 /t 5 /r /f"
chk skip $? "Could not reboot"
waiting 90
}
# Shutdown the VM and control the success via showvminfo; shutdown.exe is used because VBox ACPI-Functions are sometimes unreliable with XP-VMs.
shutdown_vm() {
log "Shutting down..."
execute "VBoxManage guestcontrol \"${vm_name}\" run --exe C:/Windows/system32/shutdown.exe --username 'IEUser' --password 'Passw0rd!' -- shutdown/args0 /t 5 /s /f"
chk skip $? "Could not shut down"
check_shutdown
}
shutdown_vm_for_removal() {
log "Shutting down for removal..."
execute "VBoxManage guestcontrol \"${remove_vm}\" run --exe C:/Windows/system32/shutdown.exe --username 'IEUser' --password 'Passw0rd!' -- shutdown/args0 /t 5 /s /f"
chk skip $? "Could not shut down for removal"
}
# Remove the given Machine from VBox and delete all associated files. Shut down the VM beforehand, if needed.
delete_vm() {
log "Removing ${remove_vm}..."
if [ ! $(VBoxManage showvminfo "${remove_vm}" | grep -q 'running') ]; then
shutdown_vm_for_removal
waiting 30
fi
execute "VBoxManage unregistervm \"${remove_vm}\" --delete"
chk skip $? "Could not remove VM ${remove_vm}"
waiting 10
}
# Change the Hostname of the VM; Avoids duplicate Names on the Network in case you set up several instances of the same Appliance.
# We copy the rename.bat because the VBox exec doesn't provide the needed Parameters in a way wmic.exe is able to apply correctly.
# Also WinXP usually fails to set the name, you can use C:\Temp\rename.bat to set it manually on the VM. Make sure to restart afterwards.
rename_vm() {
case ${vm_name} in
IE6*WinXP*)
vm_orig_name="ie6winxp"
;;
IE8*WinXP*)
vm_orig_name="ie8winxp"
;;
IE7*Vista*)
vm_orig_name="IE7Vista"
;;
IE8*Win7*)
vm_orig_name="IE8Win7"
;;
IE9*Win7*)
vm_orig_name="IE9Win7"
;;
IE10*Win7*)
vm_orig_name="IE10Win7"
;;
IE11*Win7*)
vm_orig_name="IE11Win7"
;;
IE10*Win8*)
vm_orig_name="IE10Win8"
;;
IE11*Win8*)
vm_orig_name="IE11Win8_1"
;;
*)
chk skip 1 "Could not find hostname, skip renaming..."
return 1
;;
esac
log "Preparing to change Hostname ${vm_orig_name} to ${vm_pretty_name}..."
echo 'c:\windows\system32\wbem\wmic.exe computersystem where caption="'${vm_orig_name}'" call rename "'${vm_pretty_name}'"' > ${tools_path}/rename.bat
chk skip $? "Could not create rename.bat"
log "Copy rename.bat..."
#execute "VBoxManage guestcontrol \"${vm_name}\" copyto '/tmp/rename.bat' "${vm_temp}" --username 'IEUser' --password 'Passw0rd!'"
copyto rename.bat "${tools_path}" "${vm_temp}"
chk skip $? "Could not copy rename.bat"
log "Launch rename.bat..."
execute "VBoxManage guestcontrol \"${vm_name}\" run --exe '${vm_temp}rename.bat' --username 'IEUser' --password 'Passw0rd!'"
chk skip $? "Could not change Hostname"
waiting 5
}
configure_clipboard() {
log "Changing Clipboard-Mode to bidirectional..."
VBoxManage controlvm "${vm_name}" clipboard bidirectional
chk skip $? "Could not set Clipboard-Mode"
waiting 5
}
update_hub_ip() {
# Create a hosts file
log "Updating hub ip in guest VM hosts file..."
if [ $(uname) == "Darwin" ]
then
# This makes sense on a mac
ifconfig ${nic_bridge} | grep "inet " | awk '{print $2 " hubhost"}' > ${tools_path}/hosts
else
# This works on Ubuntu
ifconfig ${nic_bridge} | grep "inet " | awk '{print $2 " hubhost"}' | sed 's/addr://' > ${tools_path}/hosts
fi
# Send it to the VM
copyto hosts ${tools_path} "C:/Windows/System32/drivers/etc/"
chk skip $? "Could not update hub ip in guest VM hosts file"
waiting 5
}
# Check if --delete was given as second parameter to this script. The VM-Name is expected to be the third parameter.
# If no VM-Name is given --delete will be ignored.
if [ "${2}" = "--delete" ]; then
if [ ! -z "${3}" ]; then
delete_vm
else
log "Delete VM"
chk skip "--delete was given, but no VM, skipping..."
fi
fi
ex_activate_vm_xp() {
chk skip 0 "Nothing to do..."
}
ex_activate_vm_w7() {
execute "VBoxManage guestcontrol \"${vm_name}\" run --exe cmd.exe --username 'IEUser' --password 'Passw0rd!' -- cmd/args0 /C slmgr /ipk 33PXH-7Y6KF-2VJC9-XBBR8-HVTHH"
chk skip $? "Could not activate Windows"
}
ex_activate_vm_wv() {
ex_activate_vm_w7
}
ex_activate_vm_w8() {
ex_activate_vm_w7
}
activate_vm() {
execute_os_specific ex_activate_vm
}
get_vm_info
import_vm
set_network_config
set_rdp_config
disable_uac
start_vm
disable_firewall
create_temp_path
rename_vm
set_ie_config
install_java
#install_firefox
#install_chrome
install_selenium
configure_clipboard
update_hub_ip
#activate_vm
if [ "${create_snapshot}" = "True" ]; then
shutdown_vm "${vm_name}"
snapshot_vm "Selenium"
start_vm
else
reboot_vm
fi
sendmessage
================================================
FILE: mkvm_cron.sh
================================================
#!/bin/bash
# Do not remove "sleep 30" as Virtualbox tend to act strange if you run to many commands in a short time.
su vbox --shell=/bin/bash -c "/opt/mkvm.sh /opt/Appliances/xp/ie6/IE6\ -\ WinXP.ova --delete 'IE6 - WinXP'"
sleep 30
su vbox --shell=/bin/bash -c "/opt/mkvm.sh /opt/Appliances/xp/ie8/IE8\ -\ WinXP.ova --delete 'IE8 - WinXP'"
sleep 30
su vbox --shell=/bin/bash -c "/opt/mkvm.sh /opt/Appliances/win7/ie8/IE8\ -\ Win7.ova --delete 'IE8 - Win7'"
sleep 30
su vbox --shell=/bin/bash -c "/opt/mkvm.sh /opt/Appliances/win7/ie9/IE9\ -\ Win7.ova --delete 'IE9 - Win7'"
sleep 30
su vbox --shell=/bin/bash -c "/opt/mkvm.sh /opt/Appliances/win7/ie10/IE10\ -\ Win7.ova --delete 'IE10 - Win7'"
sleep 30
su vbox --shell=/bin/bash -c "/opt/mkvm.sh /opt/Appliances/win7/ie11/IE11\ -\ Win7.ova --delete 'IE11 - Win7'"
sleep 30
su vbox --shell=/bin/bash -c "/opt/mkvm.sh /opt/Appliances/vista/ie7/IE7\ -\ Vista.ova --delete 'IE7 - Vista Clone'"
sleep 30
su vbox --shell=/bin/bash -c "/opt/mkvm.sh /opt/Appliances/win8/ie10/IE10\ -\ Win8.ova --delete 'IE10 - Win8'"
sleep 30
su vbox --shell=/bin/bash -c "/opt/mkvm.sh /opt/Appliances/win8/ie11/IE11\ -\ Win8.1.ova --delete 'IE11 - Win8.1'"
sleep 30
================================================
FILE: mkvm_cronjob
================================================
# /etc/cron.d/mkvm
# cron entry for recreate modern.ie VMs
# m h dom mon dow user command
0 3 1 * * root /opt/mkvm_cron.sh
gitextract_xfvv82cn/ ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── Tools/ │ ├── ie11_win32.reg │ ├── ie_disablecache.reg │ ├── ie_protectedmode.reg │ └── selenium_conf/ │ ├── WIN7/ │ │ ├── IE10/ │ │ │ └── config.json │ │ ├── IE11/ │ │ │ └── config.json │ │ ├── IE8/ │ │ │ └── config.json │ │ └── IE9/ │ │ └── config.json │ └── selenium.bat ├── config.sh ├── mkvm.sh ├── mkvm_cron.sh └── mkvm_cronjob
Condensed preview — 16 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (37K chars).
[
{
"path": ".gitignore",
"chars": 181,
"preview": "VMs/**/*.*\nTools/*.exe\nTools/*.iso\nTools/*.msi\nTools/*.bat\nTools/hosts\n!Tools/jre-windows-i586.exe\nTools/selenium_conf/*"
},
{
"path": "LICENSE",
"chars": 1076,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2014 Denis Witt\n\nPermission is hereby granted, free of charge, to any person obtain"
},
{
"path": "Makefile",
"chars": 2674,
"preview": "all: fetch fetch_vms\n\nfetch: selenium-server deuac IEDriver\n\nfetch_vms: IE11-Win7 IE10-Win7 IE9-Win7 IE8-Win7\n\nIE11-Win7"
},
{
"path": "README.md",
"chars": 4221,
"preview": "modernie_selenium\n=================\n\nManage modern.ie VirtualBox-Appliances with Selenium-Support\n\nThis script allows to"
},
{
"path": "Tools/ie11_win32.reg",
"chars": 163,
"preview": "Windows Registry Editor Version 5.00\n\n[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATU"
},
{
"path": "Tools/ie_disablecache.reg",
"chars": 825,
"preview": "Windows Registry Editor Version 5.00\n\n[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main]\n“Start Page”=”about:"
},
{
"path": "Tools/ie_protectedmode.reg",
"chars": 593,
"preview": "Windows Registry Editor Version 5.00\n\n[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zon"
},
{
"path": "Tools/selenium_conf/WIN7/IE10/config.json",
"chars": 400,
"preview": "{\n \"configuration\": {\n \"port\": 5555,\n \"register\": true,\n \"registerCycle\": 5000,\n \"hubPort"
},
{
"path": "Tools/selenium_conf/WIN7/IE11/config.json",
"chars": 400,
"preview": "{\n \"configuration\": {\n \"port\": 5555,\n \"register\": true,\n \"registerCycle\": 5000,\n \"hubPort"
},
{
"path": "Tools/selenium_conf/WIN7/IE8/config.json",
"chars": 399,
"preview": "{\n \"configuration\": {\n \"port\": 5555,\n \"register\": true,\n \"registerCycle\": 5000,\n \"hubPort"
},
{
"path": "Tools/selenium_conf/WIN7/IE9/config.json",
"chars": 399,
"preview": "{\n \"configuration\": {\n \"port\": 5555,\n \"register\": true,\n \"registerCycle\": 5000,\n \"hubPort"
},
{
"path": "Tools/selenium_conf/selenium.bat",
"chars": 144,
"preview": "\"C:\\Program Files\\Java\\jre1.8.0_151\\bin\\java.exe\" -jar c:\\selenium\\selenium-server-standalone.jar -role node -nodeConfig"
},
{
"path": "config.sh",
"chars": 583,
"preview": "# Config; See readme for details.\njava_exe=\"jre-windows-i586.exe\"\nfirefox_exe=\"firefox.exe\"\nchrome_exe=\"chrome.exe\"\nsele"
},
{
"path": "mkvm.sh",
"chars": 20026,
"preview": "#!/bin/bash\n\n# Debug\n#set -x\n#set -e\n\nsource config.sh\n\n# Basic-Checks.\nif [ \"${1}\" = \"--help\" ]; then\n echo \"Usage: $0"
},
{
"path": "mkvm_cron.sh",
"chars": 1201,
"preview": "#!/bin/bash\n\n# Do not remove \"sleep 30\" as Virtualbox tend to act strange if you run to many commands in a short time.\n\n"
},
{
"path": "mkvm_cronjob",
"chars": 127,
"preview": "# /etc/cron.d/mkvm\n# cron entry for recreate modern.ie VMs\n\n# m h dom mon dow user command\n0 3 1 * * root /opt/mkvm_c"
}
]
About this extraction
This page contains the full source code of the conceptsandtraining/modernie_selenium GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 16 files (32.6 KB), approximately 10.2k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.