1

私のアプリケーションでは、保存ボタンをクリックすると、ダイアログに [OK] ボタンのメッセージが表示されます。「OK ボタン」の記録中に記録され、「text_ok().click(atpoint(11,8));」が表示されます。しかし、再生中に「オブジェクトが見つかりません」というエラーが表示されます。最近 RFT バージョン 8.2.2.1 を更新した後、この問題のみが見られます。この問題やJavaでのコーディングを解決する方法を教えてください。

これにより、私の回帰が待っています。あなたの助けは非常にありがたいです。前もって感謝します。

4

2 に答える 2

1

ダイアログウィンドウの種類については言及していません。ただし、RFT の IWindow API を試して、アクティブなトップ ウィンドウを見つけ、以下に指定されているようにクリックを実行することができます。
次の例のコードは、呼び出しによって html でアラート ダイアログ ボックスを処理できます。

  handleDialogButton("Message from Webpage", "ok");   

または、メモ帳の [フォント] ダイアログ ([書式] > [フォント]) で [キャンセル] ボタンをクリックするには、次のように呼び出します。

      handleDialogButton("font","cancel"); 

-------サンプルコード----

/*
 * Activates the top window with the given caption and clicks on the child control(window) with the specified text
 * @param caption- Caption of the Dialog window
 * @param btnToClick- Text of the button(any other control) to click 
 */
void handleDialogButton(String caption,String btnToClick)
{
    IWindow[] windows = getTopWindows();
    for(IWindow window: windows)
    {           
        if(window.getText().equalsIgnoreCase(caption))
        {       
            window.activate();
            //window.close(); //we can just close it also n break.              
   IWindow[] children = window.getChildren(); // OR go thru the children to get the child 
            for(IWindow child:children)
            {               
                if(child.getText().equalsIgnoreCase(btnToClick))
                {
                    child.click();                      
                    break;
                }
            }           
        }
    }
    unregisterAll();
}
于 2012-10-02T07:10:04.520 に答える
-1

Selenium Web driver API のポインティングから、次のことをお勧めします。

Alert alert = driver.switchTo().alert(); 
   alert.accept();

これがうまくいくことを願っています

于 2012-10-01T11:54:49.713 に答える