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 - Working with Iframes
Watir - Working with Iframes
Watir很容易利用yn子与 if子合作。
Syntax
browser.iframe(id: myiframe ) // will get the reference of the iframe where we want to input details.
为了了解如何处理金字塔和确定仪表内各项要素,我们将以实例开展工作。
Example
main.html
<html> <head> <title>Testing using Watir</title> </head> <body> <iframe src = "test1.html" id = "myiframe" width = "500" height = "100"></iframe> </body> </html>
test1.html
<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 b.goto( http://localhost/uitesting/main.html ) t = b.iframe(id: myiframe ).text_field t.set Riya Kapoor b.screenshot.save iframetestbefore.png t.fire_event( onchange ) b.screenshot.save iframetestafter.png
瓦伊夫法典,将iframe放在此处的圆顶上——
t = b.iframe(id: myiframe ).text_field
我们使用了上面所示的标签框架和仪表。
以上准则的筛选情况如下: