2012-03-20 37 views
2

我一直負責我們整個應用程序在測試的幾個彈出框的內容。如何使用的Watir關閉「網頁試圖關閉此頁」的消息

var win = new Window({ className: "spread", title: "Discussion", 
left: 1, width: 410, height: 300, url: "Discussion.aspx?ID=" + id, 
showEffectOptions: { duration: 0}}) 

因爲我一直無法通過彈出窗口來訪問網頁,我已經開始直接導航到該頁面:所有彈出窗口都使用類似的東西叫。問題在於頁面被設計爲在頁面處理完成後關閉。 (window.close();

測試頁面時,由於我直接訪問該頁面,因此我收到The webpage you are viewing is trying to close the window. Do you want to close this window?消息。

是否有使用的Watir(沒有的Watir-webdriven)來訪問信息並單擊是或否的方法嗎?

PS - (使用IE8,如果該事項我都試圖找到方法來禁用該消息,但無濟於事)

UPDATE 使用IE開發者工具,廣義HTML結構的彈出長相像:

<html><body> 
    <iframe><form>... (Main page here) 
    <div class="dialog"> 
    <div class="spread_close" onclick="Window.close()"/> 
    <table><tr><td><iframe> (table is not part of the "spread_close" div) 
     <html><body><form><div><table><tr><td> 
     <textarea name="txtDiscussion" id = "txtDiscussion" > 

使用browser.div(:class => "spread_close").exists?回報true

使用browser.text_field(:name => "txtDiscussion").exists?回報false。我認爲這是因爲雙重<html>

+0

可能我建議嘗試通過彈出問題來解決訪問頁面嗎?我發現通常比試圖點擊這些錯誤消息更容易。 – 2012-03-20 21:29:19

+0

你在用什麼版本的Watir? – 2012-03-21 07:45:55

+0

的Ruby 1.9.3 的Watir 2.0.4 我曾嘗試之前得到訪問彈出式廣告和與幫助,能得到訪問能夠關閉彈出窗口(感謝@ChuckvanderLinden),但即使有幫助,是無法成功訪問**彈出窗口中的字段和按鈕**。 (「Popup」可能不是最好的術語,但是我知道的最好的情況)... [link](http://stackoverflow.com/questions/8681869/trouble-attaching-to-a-javascript-window -with-watir)(鏈接到關於關閉彈出窗口的上一個問題) – swood 2012-03-21 13:16:01

回答

1

你已經有框架。這可能是什麼阻止訪問,這些實際上不是一個彈出窗口,而是一個'lightbox'div,使用樣式等來查看很多謊言彈出窗口或模式對話框。

中查找的東西就如何處理與框架上的Watir維基,你應該對你的方式。