Watir Tutorial
Selected Reading
- Watir - Discussion
- Watir - Useful Resources
- Watir - Quick Guide
- Watir - Browser Windows
- Watir - Downloads
- Watir - Alerts
- Watir - Proxies
- Watir - Cookies
- Watir - Page Performance
- Watir - Page Objects
- Watir - Capturing Screenshots
- Watir - Mobile Testing
- Watir - Headless Testing
- Watir - Automatic Waits
- Watir - Working with Iframes
- Watir - Locating Web Elements
- Watir - Web Elements
- Watir - Working with Browsers
- Watir - Installing Drivers for Browsers
- Watir - Environment Setup
- Watir - Introduction
- Watir - Overview
- Watir - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Watir - Capturing Screenshots
Watir - Capturing Screenshots
掌握屏幕照片的能力是Watir的有趣特征之一。 在测试自动化期间,你可以抽取屏幕并节省屏幕。 如果发生任何错误,可在屏幕上加以记录。
下文将讨论一个简单的例子,以及测试页,我们在那里进行了筛选。
Syntax
browser.screenshot.save nameofimage.png
Test page
<html> <head> <title>Testing UI using Watir</title> </head> <body> <script type = "text/javascript"> function wsentered() { console.log("inside wsentered"); var firstname = document.getElementById("firstname"); if (firstname.value != "") { document.getElementById("displayfirstname").innerHTML = "The name entered is : " + firstname.value; document.getElementById("displayfirstname").style.display = ""; } } </script> <span id = "spanfirstname"> Enter First Name : <input type = "text" id = "firstname" name = "firstname" onchange = "wsentered()" /> </span> <br/> <br/> <span style = "display:none;" id = "displayfirstname"></span> </body> </html>
Example
require watir b = Watir::Browser.new :chrome b.goto( http://localhost/uitesting/textbox.html ) t = b.text_field(id: firstname ) // using the id of the textbox to locate the textbox t.exists? t.set Riya Kapoor b.screenshot.save textboxbefore.png t.value t.fire_event( onchange ) b.screenshot.save textboxafter.png
我们使用Watir的屏幕显示在这里: