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 - Automatic Waits
Watir - Automatic Waits
在本章中,让我们明白,要等一些细节。 为了理解自动等待,我们创建了一个简单的测试页。 当用户进入文本箱交换活动时,在3秒之后,才允许纽伦。
Watir有wait_unit。 a 等待特定事件或财产的电话。 我们将对以下试验页进行测试:
Syntax
browser.button(id: btnsubmit ).wait_until(&:enabled?) //here the wait is on the button with id : btnsubmit to be enabled.
testwait.html
<html> <head> <title>Testing UI using Watir</title> </head> <body> <script type = "text/javascript"> function wsentered() { setTimeout(function() { document.getElementById("btnsubmit").disabled = false; }, 3000); } function wsformsubmitted() { document.getElementById("showmessage").style.display = ""; } </script> <span id = "spanfirstname"> Enter First Name : <input type = "text" id = "firstname" name = "firstname" onchange = "wsentered()" /> </span> <br/> <br/> <button id = "btnsubmit" disabled oncpck = "wsformsubmitted();">Submit</button> <br/< <br/< <span id = "showmessage" style = "display:none;color:green;font-size:25px;">l; Button is cpcked </span> </body> </html>
Output
当你进入文本箱时,你将不得不等待3秒才能使纽芬兰成为可能。
当你点击Submitutton时,展示了以下案文:
现在,由于我们增加了使纽托邦能够进入的拖延,因此很难进行自动化处理。 每当我们出现一些拖延或不得不等待某一事件或将要找到的那部分财产时,我们就可以利用等待——如下所示——
Watir code using wait_until
require watir b = Watir::Browser.new :chrome b.goto( http://localhost/uitesting/testwait.html ) t = b.text_field(name: firstname ) t.exists? t.set Riya Kapoor b.screenshot.save waittestbefore.png t.value t.fire_event( onchange ) btn = b.button(id: btnsubmit ).wait_until(&:enabled?) btn.fire_event( oncpck ); b.screenshot.save waittestafter.png
其次,使用以下指挥系统:
btn = b.button(id: btnsubmit ).wait_until(&:enabled?)
瓦伊尔将等到纽顿才获得许可,随后将进行点击。 播放的屏幕如下: