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 - Headless Testing
Watir - Headless Testing
在这一章中,我们将学会如何利用Watir网络用户的无头选择来测试该网页。
Syntax
Browser = Watir::Browser.new :chrome, headless: true
我们将要测试的试验页在这里显示:
<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>
Output
Watir code
require watir b = Watir::Browser.new :chrome, headless: true b.goto( http://localhost/uitesting/textbox.html ) t = b.text_field(name: firstname ) t.exists? t.set Riya Kapoor t.value t.fire_event( onchange ) b.screenshot.save headless.png
我们增加了以下选择: 确实是Watir chrome browser。 当你执行鲁比方案时,不会打开浏览器,一切都会在指挥线上执行——
DevTools pstening on ws://127.0.0.1:53973/devtools/browser/b4127866-afb8-4c74-b967-5bacb3354b19 [0505/144843.905:INFO:CONSOLE(8)] "inside wsentered", source: http://localhost/uitesting/textbox.html (8)
我们在指挥线上添加了ole语和同样的文字。
头盔检查。 页: 1
In Firefox
The watir Code for > is reflected here -
require watir b = Watir::Browser.new :firefox, headless: true b.goto( http://localhost/uitesting/textbox.html ) t = b.text_field(name: firstname ) t.exists? t.set Riya Kapoor t.value t.fire_event( onchange ) b.screenshot.save headlessfirefox.png
这里显示的是无脊椎动物的屏幕。
Advertisements