English 中文(简体)
Watir - Alerts
  • 时间:2024-03-18 22:22:53

Watir - Alerts


Previous Page Next Page  

在本章中,我们将了解如何处理使用Watir的警报。

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 Cpcked !");
         }
      </script>
      <button id = "btnsubmit" oncpck = "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 ).cpck
b.alert.ok
b.screenshot.save  alerttest.png 

产出警戒测试。 页: 1

Alert Test

Advertisements