您的位置:軟件測試 > 開源軟件測試 > 開源功能測試工具 >
WatiN 如何處理彈出警告
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時間:[ 2013/12/4 11:30:22 ] 推薦標(biāo)簽:

Watin對Web頁面彈出窗口,對話框,提示框的處理

處理彈出窗口

 首先創(chuàng)建一個web頁,用于演示彈出窗口。

<inputid="Button1"type="button"value="button"onclick="openwindow()"/>

   <scripttype="text/javascript">

   functionopenwindow()

     {

         window.open("http://localhost/Test/test2.htm");

     }

   </script>

上述代碼,點擊“Button1”后,彈出窗口test2.htm.我們要做的是如何處理test2.htm頁面

Watin處理代碼如下:

IEie =newIE("http://localhost/Test/");

//點擊按鈕,打開新窗口test2

ie.Button(Find.ById("Button1")).Click();

//查找新窗口test2并賦給新的IE對象

IEnewie =IE.AttachTo<IE>(Find.ByTitle("test2"));

//使用新的IE對象可以繼續(xù)對新窗口進(jìn)行操作了

newie.TextField(Find.ById("Text1")).TypeText("this is new ie");

  處理confirm彈出框

 首先創(chuàng)建一個web頁,用于演示confirm對話框。

<inputid="myButton1"type="button"value="this is a button"

     onclick="confirmMe(); return false;"><br>

   <script>

     functionconfirmMe() {

       varanswer = confirm ("Are you having fun?")

       if(answer)

         document.getElementById("myButton1").value="Clicked OK";

       else

         document.getElementById("myButton1").value="Clicked Cancel";

     }

   </script>

上一頁123下一頁
軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd