Alerts

Syntax

browser.alert.exists? browser.alert.ok browser.alert.close

Testpage

<html> <head> <title>Testing Alerts Using Watir</title> </head> <body> <script type = "text/javascript"> function wsformsubmitted() { alert("Button is Clicked !"); } </script> <button id = "btnsubmit" onclick = "wsformsubmitted();">Submit</button> </body> </html>

Watir Code

require 'watir' b = Watir::Browser.new :chrome b.goto('http://localhost/uitesting/testalert.html') b.button(id: 'btnsubmit').click b.alert.ok b.screenshot.save 'alerttest.png'

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *