first configure a Linux development environment with vagrant:
Vagrant is just a portable tool that allows you to easily set up the virtual machine you want, with the underlying support for VirtualBox, VMware, and even AWS as a virtual machine system, which we'll use VirtualBox to illustrate, So the first step is to install Vagrant and VirtualBox first.
VirtualBox Installation:, Muggle installation, any path https://www.virtualbox.org/wiki/Downloads
vagrant Installation: The latest version of Vagrant has been unable to install through the gem
command, because there are too many dependent libraries, so currently can not be used gem
to install, the current network of many tutorials are similar to such commands, those are wrong. Recommended website Download the installation package, such as the installation of https://www.vagrantup.com/downloads.html on Muggle
Generally download the installation of these two are ready OK, but sometimes win under some strange unpredictable error, I installed the second time met ... This patch will okhttp://download.virtualbox.org/virtualbox/5.0.10/oracle_vm_virtualbox_extension_pack-5.0.10-104061.vbox-extpack.
OK, ready for work above ready
Type the following command:
mkdir ubuntu14.04
CD ubuntu14.04
Vagrant Init ubuntu/trusty64 #init back, that's the name of the virtual machine.
# Modify the created Vagrantfile configuration file generates a Vagrantfile profile in the current directory
Vagrant up
Vagrant SSH
General win does not support vagrant SSH, will error: SSH client not found, need to install a third-party customer service to connect, recommended here Msys, it can create a similar experience under the Linux Shell/HTTP/ sourceforge.net/projects/msys2/
After downloading the MSYS2 package, run the installation as follows.
$ pacman--needed-sy Bash Pacman pacman-mirrors msys2-runtime
$ pacman-su
$ pacman-s git #安装git和ssh easy for you to use git under win
Above, completed the Vagrant Linux development environment to build.
Installing Webdriver I/o:
I'm using Nodejs to do selenium2.0 development, start Ubuntu with Msys2 shell.
I'm faking the command line. Ubuntu no interface, install a XVFB to simulate the x-server end
sudo apt-get install xvfb
#安装xvf
sudo apt-get install firefox #安装Firefox
安装java
$ sudo apt-add-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java7-installer
$ export JAVA_HOME=/usr/lib/jvm/java-7-oracle # append to your ~/.profile file.
安装nodejs
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.2/install.sh | bash
$ nvm #nvm nodejs版本管理器 看是否有输出,有就安装成功了
$ nvm install 0.12 #可取官网查看最新版本 nvm可多样管理这里不作熬诉
安装selenium-standalone server
$ NPM Install [email protected]-g$ selenium-standalone install$ xvfb-run--server-args="-screen 0, 1366x768x24" selenium-standalone start
Open another shell after completion this is a server side of the simulation
Test preparation
$ mkdir my-test$CD my-test$ NPM init-y# Initialize NODEJS project $ npm Install Webdriverio#安装 Webdriverio Package $ nano baidu-test.js$# vim Baidu-test.js #nano
With a small test of Baidu
Baidu-test.js
#
var Webdriverio = require (' Webdriverio ');
var options = {
Desiredcapabilities: {
Browsername: ' Firefox '
}
};
var browser = Webdriverio
. Remote (options)
. Init ();
Browser
. URL (' https://www.baidu.com ')
. title (Function (err, res) {
Console.log (' Title was: ' + res.value);
})
. end ();
#
$ node Baidu-test.js
Title was: Baidu a bit, you know
If you're interested in Coffeescript, you can test it with coffee.
Baidu-test.coffee
#
Webdriverio = Require ' Webdriverio '
Options =
Desiredcapabilities:
Browsername: ' Firefox '
Webdriverio
. Remote Options
. Init ()
. url ' https://www.baidu.com '
. Title (Err, RES)
Console.log ' Title was: ' + res.value
. End ()
# This is a comments
#
$ NPM install-g Coffee (install)
$ Coffee Baidu-test.coffee
Title was: Baidu a bit, you know
In the accompanying JavaScript and coffeescript syntax contrast http://coffeescript.org/
IBM Translate Chinese document http://www.ibm.com/developerworks/cn/views/web/libraryview.jsp?search_by=%E5%88%9D%E6%AD%A5%E4%BA%86% E8%a7%a3+coffeescript
These are the development environments that I recently learned to use vagrant to build virtual machines based on Nodejs selenium automated testing.
The first time to write Bo, I hope you have a lot of advice!
———— Dognie
Automated test development environment Setup