Skip to main content

Web Automation Testing Framework Watir (Ruby-based) - Chapter 1 Installation and Deployment under Windows

Web Automation Testing Framework Watir (Ruby-based) - Chapter 1 Installation and Deployment under Windows

I. Preface

[[Automation Testing](/search?q=Automation Testing)](https://so.csdn.net/so/search?q=Web%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95&spm=1001.2101. 3001.7020 "Web automation testing") has been a more pressing issue for the current web development of agile development, but there is no corresponding agile testing, so open this topic, while researching, while the Web automation testing applied to the work, and then formed to be able to independently form a chapter of the blog, I hope to be able to do for the development of domestic web automation testing a little bit of modest contribution to it!I hope that I can make a small contribution to the development of web automation testing in China.

Second, Watir build process

Web automation testing framework Watir(based on Ruby) - Chapter 1 Windows installation and deployment

Figure 1-1 Tools to install

Download: Install Ruby on Rails - Railsinstaller.org -

Because there are a number of other development toolsets that are required to install Ruby, it is recommended that you get them from the website Install Ruby on Rails - Railsinstaller.org -, and if you use this installer, it will help you to set up the environment variables as well, the version I use is: railsinstaller-2.2.4.exe, it is recommended to download the latest version.

Web Automation Testing Framework Watir\ (based on Ruby) - Chapter 1 Installation and Deployment under Windows

Figure 1-2 RailsInstaller toolkit installation screen

To begin installing the RailsInstaller toolkit, just install it to the default location.

[Web Automation Testing Framework Watir\ (based on Ruby) - Chapter 1 Installation and Deployment under Windows]

Figure 1-3 Installation Completion Screen

This check mark is recommended, it will help you configure git and ssh, the installation process, ruby and a series of environment variables are also configured OK, quite good ~!

Web automation testing framework Watir\ (based on Ruby) - Chapter 1 Windows installation and deployment

Figure 1-4 Testing the Ruby installation

After installing railsinstaller-2.2.4.exe, open the cmd command line, enter the command: ruby -v, if, the appearance of the version of ruby as shown in Figure 1-4, it means that ruby has been installed, we can also enter the command to test the gem version: gem -v, as shown in Figure 1-4, gem is also installed successfully.

Web Automation Testing Framework Watir\ (based on Ruby) - Chapter 1 Installation and Deployment under Windows

Figure 1-5 gem installation

Using the command: gem list, take a look, as in Figure 1-5, you'll see that railsinstaller, once installed, does not include the Watir automated test tool by default, so we'll start installing watir now.

Web Automation Testing Framework Watir(Ruby\based) - Chapter 1 Installation and Deployment under Windows

Figure 1-6 The gem command

Let's start with a brief look at how gem works, as shown in Figure 1-6 above.

Web Automation Testing Framework Watir\ (based on Ruby) - Chapter 1 Installation and Deployment under Windows

Figure 1-7 Install watir command

Use the command: gem install watir, to install watir, and if it goes well, a lot of text such as successfully will appear below; however, in China, you usually don't see text such as successfully because RubyGems.org | your community gem host has been walled off, and now we're going to modify the gem's source a bit for the purpose of installing watir.

Web Automation Testing Framework Watir(based on Ruby) - Chapter 1 Installation and Deployment under Windows

Figure 1-8 RubyGems mirror URLs

First use the command: gem sources -l to check the current source of the gem, which is usually: RubyGems.org | your community gem host

Then we use the command: gem sources --remove RubyGems.org | your community gem host

Then enter the command: gem sources -a https://ruby.taobao.org/

Refer to the image above.

Web Automation Testing Framework Watir\ (based on Ruby) - Chapter 1 Installation and Deployment under Windows

Figure 1-9 Viewing the gem's source

Now look at gem's sources again this is whether it is correct: gem sources -l, if there is only: https://ruby.taobao.org/, a source, then the configuration is correct. Then use the command install watir again: gem install watir, and this time you should be able to install it successfully.

Web Automation Testing Framework Watir(Ruby\based) - Chapter 1 Installation and Deployment under Windows

Web Automation Testing Framework Watir\ (based on Ruby) - Chapter 1 Installation and Deployment under Windows

Figure 1-10 commonwatir and watir versions

We can use the command: gem list again, you can see that there are so many contents related to watir inside the list, here the main concern is two tools, as shown in the figure above, commonwatir and watir, here you need to downgrade the version of commonwatir and watir to 3.0.0, if you don't do the downgrade, you will get a NameError error, the command is as follows:

Web Automation Testing Framework Watir(based on Ruby) - Chapter 1 Installation and Deployment under Windows

Figure 1-11 watir downgrade to 3.0.0

Enter the command: gem uninstall watir -v 5.0.0

Enter the command: gem install watir -v 3.0.0

Web Automation Testing Framework Watir(Ruby\based) - Chapter 1 Installation and Deployment under Windows

Figure 1-12 commonwatir downgrade to 3.0.0

Enter the command: gem uninstall commonwatir -v 4.0.0

Enter the command: gem install commonwatir -v 3.0.0 Web Automation Testing Framework Watir(based on Ruby) - Chapter 1 Installation and Deployment under Windows

Figure 1-13 ruby test code

require "watir"

puts "Open IE..."

ie=Watir::IE.new

ie.goto(Baidu, you will know)

puts "IE is opened - enjoy it :)"

Create a new test.rb file in a text editor and enter the above code, manual input is highly recommended, careless spaces can also cause the run to fail.

Web Automation Testing Framework Watir\ (Ruby\based) - Chapter 1 Installation and Deployment under Windows

Figure 1-14 ruby file encoding

Be careful with the encoding as well, use UTF-8 encoding. Web Automation Testing Framework Watir\ (based on Ruby) - Chapter 1 Installation and Deployment under Windows

Figure 1-15 Test effect

will test.rb saved, in the cmd command line enter the command: ruby test.rb If the ruby code does not report errors, the program will automatically open the IE browser, automatically enter Baidu, you will know, open the Baidu page. At this point, the "Windows environment to build Web automated testing framework Watir (based on Ruby) Chapter 1" is written.

Third, this chapter summarizes

we through a series of configurations, ruby and watir deployed to the windows platform, the next step, we can write a variety of test scripts for different web applications, different tests.

** As a software testing over, I want to do my best to help every partner can successfully find a job. So I organized the following this resource, and now share it with you for free, and the partners who need it can pay attention to [public number: happy snail powder] self-pickup!**

Web Automation Testing Framework Watir(based on Ruby) - Chapter 1 Installation and Deployment under Windows

Software Testing Interview Document

We are bound to learn in order to find a well-paid job, the following interview questions are from Ali, Tencent, bytes, and other first-line Internet factories the latest interview information, and byte big brother gave an authoritative answer, brush this set of interview information believe that we can find a satisfactory job.Web Automation Testing Framework Watir\ (based on Ruby) - Chapter 1 Installation and Deployment under Windows

Web Automation Testing Framework Watir\ (Ruby\based) - Chapter 1 Installation and Deployment under Windows

Take action, it is better to be on the road than to keep watching, and you will certainly thank yourself for fighting now in the future!If you want to learn to improve can not find the information, no one to answer questions and solve problems, ** please join the group in a timely manner: ****** [1150305204] (https://blog.csdn.net/shanmao04/article/details/135536863?_wv=1027&k=) W6hw4YAnQQteqV3nTEeWF8JOe2qhXRyQ&authKey=42%2F0tLnnzL83chxtjg5voSS6FTETjcKhwXPVSc0z4rtmw0kRZ%2FgMTZkaqBsLIdjM&noverify=0&group_ code=1150305204 "1150305204")******** , which has a variety of test development information and technology can be exchanged together Oh.

Web Automation Testing Framework Watir\ (based on Ruby) - Chapter 1 Installation and Deployment under Windows