2011-10-27 18 views
0

我会发布一个示例,并想知道在不停止脚本的情况下,“IDEAL”窗口中的IDE操作的解决方案是什么。我会 提供一个在线的例子,我建立的脚本:没有详细 工作...Selenium ShowDialogic Modal

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<link rel="selenium.base" 
    href="http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialog2.htm" /> 
<title>New Test</title> 
</head> 
<body> 
    <table cellpadding="1" cellspacing="1" border="1"> 
     <thead> 
      <tr> 
       <td rowspan="1" colspan="3">New Test</td> 
      </tr> 
     </thead> 
     <tbody> 
      <!--//Open the application and wait to load the combobox--> 
      <tr> 
       <td>open</td> 

       <td>/workshop/samples/author/dhtml/refs/showModalDialog2.htm</td> 
       <td></td> 
      </tr> 
      <tr> 
       <td>waitForElementPresent</td> 

       <td>name=oHeight</td> 
       <td></td> 
      </tr> 
      <!--//Insert height value and click "Push To Create" button--> 
      <tr> 
       <td>select</td> 

       <td>name=oHeight</td> 
       <td>label=250</td> 
      </tr> 
      <tr> 
       <td>click</td> 
       <td>css=input[type=&quot;button&quot;]</td> 
       <td></td> 
      </tr> 
      <!--//Wait for the loading the modal page title and check the text --> 
      <tr> 
       <td>waitForElementPresent</td> 

       <td>//h1</td> 
       <td></td> 
      </tr> 
      <tr> 
       <td>verifyTextPresent</td> 
       <td>This is a modal dialog box. This page is not designed to do 
        anything except display the dialog box arguments.</td> 
       <td></td> 
      </tr> 
      <!--//close the screen and verify that the previous screen is loaded from the height field--> 
      <tr> 
       <td>close</td> 
       <td></td> 

       <td></td> 
      </tr> 
      <tr> 
       <td>selectWindow</td> 
       <td>null</td> 
       <td></td> 
      </tr> 
      <tr> 
       <td>waitForElementPresent</td> 
       <td>name=oHeight</td> 
       <td></td> 
      </tr> 

     </tbody> 
    </table> 
</body> 
</html> 

回答

0

Web应用程序实际上没有模式对话框,用浏览器对话框的异常(如 “将文件另存为...”)和JavaScript的window.alert(),window.prompt()window.confirm()。其他的东西或者是一个单独的窗口(如传统的网络应用程序),或者是一个覆盖,阻止访问它后面的元素(如现代的AJAXy,网络应用程序)。

在单独的窗口的情况下,您需要waitForPopUp ...windowname...然后selectWindow ...windowname...,然后selectWindow(没有名称)切换回来。

在覆盖的情况下,您可以像处理页面中的其他任何东西一样解决它,但是您可能会惊讶元素定位器可能是什么(或者您可能不会)。使用Firefox的“XPather”或“Firebug”插件来找出正确的XPath表达式。

+0

你可以修改脚本使其工作吗? TKS –