在RFT中关闭当前激活窗口的两种方法
来源:互联网 发布:2005年网络歌曲大全 编辑:程序博客网 时间:2024/05/12 07:08
在RFT中,一般关闭一个窗口对象使用的是对象的close方法,例如:
计算器window().close();
但是在某些情况下,可能需要采用下面两种更为灵活的方法:
方法1:
public void closeActiveWindow()
{
IWindow activeWindow = getScreen().getActiveWindow();
if ( activeWindow != null )
activeWindow.close();
}
这种方法先取到当前处于激活状态的窗口,然后作为IWindow对象调用其close方法来关闭窗口。
方法2:
public void acceptActiveWindow()
{
IWindow activeWindow = getScreen().getActiveWindow();
if ( activeWindow != null )
activeWindow.inputKeys("{ENTER}");
}
这种方法先取到激活状态的窗口,然后调用其inputkeys方法,发送回车键,一般会把窗口中的确定或取消按钮按下,从而关闭窗口。
关于getScreen和getActiveWindow,可参考RFT的帮助文档:
getScreen
public static IScreen getScreen()
Returns an interface to the screen object. This is provided to allow scripting a solution for various situations. This method is never recorded. Any script that uses this method is probably platform specific.
Since:
RFT1.0
通过IScreen对象可以调用的方法如下:
windowFromHandle
IWindow windowFromHandle(long handle)
Returns a window object when given a native window handle.
Parameters:
handle
- The handle for the object
Returns:
IWindow the IWindow object for the handle
Detail description:
Given the handle, returns an IWindow
object
Example:
Given the handle, return the equivalent IWindow
long handle = 262476; //Handle for a window
IScreen scr = getRootTestObject().getScreen();
IWindow win =scr.getwindowFromHandle(handle);
Since:
RFT6.1.1.1
windowFromPoint
IWindow windowFromPoint(java.awt.Point point)
Returns a IWindow object at the given screen point.
Parameters:
point
- java.awt.Point The point on the screen
Returns:
IWindow The IWindow for the given point. The child's IWindow is given instead of the parent's IWindow
Detail description:
Return a IWindow
object when given a point. If the screen point is on a child window, the child, not the parent, is returned.
Example:
Get the IWindow object located at the screen point 10,10.
java.awt.Point pt = new java.awt.Point(10,10);
IScreen scr = getRootTestObject().getScreen();
IWindow win =scr.windowFromPoint(pt);
Since:
RFT6.1.1.1
getActiveWindow
IWindow getActiveWindow()
Returns the current active window.
Returns:
IWindow
Detail description:
Provides access to the current active visible IWindow
in the screen. The API can come to help in cases when the dialogs are not recognized.
Example:
Get the rectangle of the current active window
IScreen scr = getRootTestObject().getScreen();
IWindow win =scr.getActiveWindow();
java.awt.Rectangle rect = win.getScreenRectangle();
Since:
RFT6.1.1.1
getMousePosition
java.awt.Point getMousePosition()
Returns the current screen location of the mouse pointer.
Returns:
java.awt.Point The current location of the cursor in the screen.
Detail description:
Use the method to gain access to current cursor location in the screen.
Example:
Get the current cursor location in the screen
IScreen scr = getRootTestObject().getScreen();
java.awt.Point screenPt =scr.getMousePosition;
Since:
RFT6.1.1.1
inputKeys
void inputKeys(java.lang.String keys)
Sends the key events to the current active window.
Parameters:
keys
- java.lang.String The keys to be sent to the current active window
Detail description:
In addition to sending characters, inputKeys helps in sending key strokes that of ALT, SHIFT, ENTER etc.. No window activation implicitly occurs. For detailed explanation of the key syntax, see inputKeys
.
Example:
Send "AB" to the top window that can consume the screen key events
IScreen scr = getRootTestObject().getScreen();
scr.inputKeys("+a+b");
Since:
RFT6.1.1.1
inputChars
void inputChars(java.lang.String characters)
Sends the characters to the current active window
Parameters:
characters
- java.lang.String The characters to be sent to the current active window
Detail description:
The characters to the current active window are sent as a sequence of key events. No special interpretation of the characters (such as for inputKeys
) is used. No window activation implicitly occurs.
Example:
Send "AB" to the top window that can consume the screen key events
IScreen scr = getRootTestObject().getScreen();
scr.inputKeys("AB");
Since:
RFT6.1.1.1
- 在RFT中关闭当前激活窗口的两种方法
- 在RFT中关闭所有IE浏览器窗口的3种方法
- 关闭当前窗口的方法
- 两种关闭窗口的方法
- 关闭窗口的两种方法
- 在RFT中根据指定的标题查找顶层窗口
- 在RFT中查找窗口中指定名称的对象
- MFC MDI在CFormView中当前关闭窗口的代码
- 如何在游戏窗口中激活当前输入法
- 关闭窗口弹出提示的两种处理方法
- 关闭浏览器窗口的两种方法分析
- 关于C#打开窗口的同时关闭自身窗口的两种实现方法
- 解决Firefox中有时使用window.close()脚本无法关闭当前窗口的方法
- Swing_JFream关闭窗口的两种方式
- 一种在父窗口中得知 window.open()出的子窗口关闭事件的方法
- 在父窗口中得知window.open()出的子窗口关闭事件的方法
- win7 激活的两种方法
- pycharm的两种激活方法
- UNIX网络编程 第2卷 进程间通信 代码安装 (转)
- Java 标准日志工具 Log4j 的使用(附源代码)
- S60实现带参数启动进程
- 网站导航设计趋势案例集合
- 《APUE》和《UNP》文件的编译和使用(转载)
- 在RFT中关闭当前激活窗口的两种方法
- 如何在Source Insight中查看ARM的汇编代码
- error C1902: Program database manager mismatch;please check your installation
- Header中的Cache-control
- 如何使Source Insight的格式显示与ADS统一
- 不要直接对Request.Headers["If-Modified-Since"]使用Convert.ToDateTime
- 《Java编程那些事儿》书籍前言和目录
- asp代码加密方法及破解
- ubuntu svn