Web Automation testing has always been a more pressing problem.
Figure 1-1 Tools required for installation
http://railsinstaller.org/
because installing Ruby also requires a few other development tools, it is recommended to download it from the website http://railsinstaller.org/, and it will help you set the environment variables as well, using the installation package. The version I am using is: Railsinstaller-2.2.4.exe, it is recommended to download the latest version.
Start installing the Railsinstaller kit and install it to the default location.
This checkmark is recommended, it will help you configure git and SSH, the installation process of a series of environment variables such as Ruby also configured OK, very good ~
Figure 1-2 Testing Ruby Installation
After installing Railsinstaller-2.2.4.exe, open the cmd command line and enter the command: RUBY–V
If, in the case of Ruby, shown in Figure 1-2, Ruby is already installed, we can also enter a command to test the version of the gem: gem–v
As shown in 1-2, the gem is also installed successfully.
Using the command: Gem list, you will find that after Railsinstaller installation, the default is not to include the Watir Automated test tool, so we will now start installing Watir.
Let's take a quick look at how the gem is used, as shown in
Use the command: Gem install Watir, to install Watir, if smooth, the following will appear a lot of successfully and other text, but in the country, you generally do not see successfully and other words, because https:// rubygems.org/has been wall, now we have to modify the source of the gem, to achieve the purpose of installing Watir.
First Use the command: Gem sources-l, check the current source of the gem, generally: https://rubygems.org/
Then we use the command: Gem sources--remove https://rubygems.org/
Then enter the command: Gem sources-a https://ruby.taobao.org/
Reference.
Look at the source of the gem. This is true: Gem Sources-l, if only: https://ruby.taobao.org/, a source, the configuration is correct.
Then use the command installed Watir:gem install Watir, this time should be able to install successfully.
We can use the command again: Gem list, you can see that the list contains a lot of watir related content, here are mainly concerned about the two tools, as shown, Commonwatir and Watir, Here you need to give Commonwatir and Watir to 3.0.0, if you do not downgrade, there will be a nameerror error, the command is as follows:
>gem Uninstall watir-v 5.0.0 >gem install watir-v 3.0.0
Next: >gem uninstall commonwatir-v 4.0.0 >gem install commonwatir-v 3.0.0
require "Watir"
"Open IE ... "
Ie
=watir::ie. New
Ie.
Goto ("http://www.baidu.com/"
) puts "IE is Opened-enjoy it:) "
Create a new test.rb file in the text editor, enter the above code, it is strongly recommended to enter manually, the space inadvertently will also cause the failure of the operation.
The coding should also be noted that
After saving the TEST.RB, enter the command on the cmd command line: Ruby TEST.RB If the Ruby code is not error-free, the program will automatically open IE browser, automatically enter
http://www.baidu.com/
, open the Baidu page.
At this point, the Windows environment Builds Web Automation test framework Watir (based on Ruby) is complete.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Windows environment builds Web Automation test framework Watir (based on Ruby)