then the Watir-webdriver Automation test scheme and implementation based on Ruby (III.)Http://www.cnblogs.com/Javame/p/4159468.html continue ... First recall our system architecture, and then talk about the specific implementation.
The automated testing framework is divided into three modules: test use case, control layer, Tools tool class, Model master control.
Test use case
- Ruby-based Watir-webdriver development
- Uniform preset parameter input rules, provide a rule template, do a use case a class, a method of one output. (A class can be multiple methods)
- Unified output rules, such as: ①[info]②tistone③login successful! ④001011
①[info]: On behalf of the use case executed successfully! [ERROR] stands for failure! [Warn] represents a warning!
②tistone: Represents the execution case name
③login successful! : Describes or captures the value values to "! "End
④001011: Return code
4. Uniform use case name, should be consistent with output ②
Control layer
- A use case corresponds to a control
- Validation output, determine the success or failure of the use case, according to the rules associated Linux server capture related logs, configuration files and other reasons for analysis failure, reduce the location area range.
- Compare data, correlate MySQL query data, and compare Web Capture value.
Tools Tool Class
- Package Tool Class
- Associating Linux with MySQL
- Provides test case support to reduce the difficulty of use case development
Index Total Control
- Control case execution and presentation
Scenario Design test use case
Involves dependencies:
Require ' watir-webdriver ' require ' watir-webdriver-performance '
Page Load Performance monitoring
1.times do B.goto ("Https://192.168.10.1/web") Load_secs = b.performance.summary[:response_time]/1000puts "Load Time: # {load_secs} seconds. " End
Identification of functional success
If B.text.include? ' t_100m ' #捕获web属性value值 #后续操作 puts "①[info]②tistone③login successful! 000000 "Else #后续操作 #输出错误码 puts" ①[error]②tistone③login failed! 001011 "End
Parametric extraction
Class Basicnumber def initialize (number,name) @number = number @name = name end def add (x) @number + x endend
Control layer
Involves dependencies:
Load ' linux.rb ' load ' mysql.rb '
The concrete realization communicates with the tools, makes the information transmits the hub.
Tools Tool Class
Involves dependencies:
Require ' net/ssh ' require ' scp/ssh ' require ' test/unit '
Associating Linux
#ip/username/Password host = "192.168.48.233" username = "root" password = "root" #调用linux命令server_cmd1 = ' Tail-1000/home/log/web.log grep ERROR ' server_shell= ' sh/home/wyong/w.sh '
Associated MySQL
Specific implementation of a slightly ...
Unit Test
Class Tc_mytest < Test::unit::testcase def Test_add n=basicnumber.new (134) assert_equal ( N.add (4), "This test on add is failure!") EndEnd
Model Master Control
Involves dependencies:
Load Control_ use case name. RB '
Unified invocation
t = Control_ use case name. Newtest_methods = T.public_methods.grep (/^test_/) Test_methods.each do |test| T.send (test) end
Watir-webdriver Automation test scheme and implementation based on Ruby (IV.)