200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > 利用watir自动化测试并截图 截图后保存

利用watir自动化测试并截图 截图后保存

时间:2020-07-09 03:04:59

相关推荐

利用watir自动化测试并截图 截图后保存

利用watir自动化测试并截图,截图后保存

保存方式:

1,同级目录

2,下级目录

3,上级目录

#-------------------------------------------------------------------------------------------------------------#

# demo test for the WATIR controller web elements and capture screen

#

# Simple GLS PORTAL test written by Tina /12/26

# Purpose: to demonstrate the following WATIR functionality:

# * entering text into a text field

# * clicking a button

# * caputure the screen

# * save in the same folder

# * save in the children folder

# * save in the father floder

#

#------------------------------------------------------------------------------------------------------------ #

def test_screencapture

# Create browser object

ie = Watir::IE.new

#~ # Open a web page we want to test.

puts "## Beginning of test: watir hand error and capture screen"

puts " "

puts "Step 1: go to the gls portal"

ie.goto("url")

ie.wait

puts "Action: have been gone to the gls portal"

puts " "

puts "Step 2: enter all interrelated information so as to login"

ie.text_field(:name , "txtCompanyID").set("cx")

ie.text_field(:name , "txtPassword").set("GLSDG")

#caputure screen in the children folder

$fileName = Dir.getwd.tr('/','//') +"//image//login_screencapture"

File.delete( $fileName+".JPG") if FileTest.exists?( $fileName+".JPG")

screen_capture($fileName,true)

puts "Action: entered all interrelated information, login successfully"

puts " "

puts "Step 3: click the 'submit' button"

ie.button(:value , "Submit").click

puts "Action: clicked the 'submit' button."

puts " "

#caputure screen in the father folder

topdir=File.join(File.dirname(__FILE__), '..')

Dir.chdir(topdir)

$fileName = Dir.getwd.tr('/','//') +"//screencaptureimage//maintenance_screencapture"

File.delete( $fileName+".JPG") if FileTest.exists?( $fileName+".JPG")

screen_capture($fileName,true)

puts " "

# logout & close the IE bowser

puts "Step 4: logout & close the IE bowser"

ie.link(:text , "Logout").click

#caputure screen in the same folder

$fileName = Dir.getwd.tr('/','//') +"//screen_capture//logout_screencapture"

File.delete( $fileName+".JPG") if FileTest.exists?( $fileName+".JPG")

screen_capture($fileName,true)

ie.close

puts "Step 4: logout & close the IE bowser successfully"

end # end test method

end

end

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。