在RFT中根據指定的標題查詢頂層視窗
在RFT中提供了豐富的底層介面(如IWindow),可以讓我們實現很多底層的物件操作,例如根據給定的標題查詢頂層視窗:
IWindow window = getTopWindowWithCaption( "計算器" , true );
if (window != null )
{
window.activate();
window.close();
}
IWindow[] windows = getTopWindowsWithCaptionPattern( ".*記事本" , true );
if (windows!= null )
{
for ( int i=0;i<windows. length ;i++)
{
windows[i].activate();
windows[i].close();
}
}
getTopWindowWithCaption函式如下,其作用是根據給定的標題(Caption)查詢頂層視窗,返回第一個找到的視窗:
/**
* Given the expected caption find a top level window that has that caption.
* The first window found with the caption is returned.
*
* @param caption The caption of the desired window.
* @param ignoreCase Flags if case i significant in the caption comparisons.
* @return The first top level window with the specified text that is located.
*/
protected IWindow getTopWindowWithCaption(String caption, boolean ignoreCase)
{
if ( caption == null )
caption = "" ;
IWindow[] topWindows = getTopWindows ();
int length = ( topWindows != null ? topWindows. length : 0 );
for ( int i = 0; i < length; ++i )
{
String text = topWindows[i].getText();
if ( ( !ignoreCase && caption.equals(text) ) ||
( ignoreCase && caption.equalsIgnoreCase(text) ) )
return topWindows[i];
}
return null ;
}
函式中的getTopWindows方法將返回當前系統中的所有視窗物件。
getTopWindowsWithCaptionPattern函式如下,支援正規表示式給定Caption,返回所有匹配的視窗物件。
/**
* Given the expected caption pattern find all top level windows that have a caption
* that matches the pattern. Basically if the pattern is "^Notepad - " all top level
* windows that have a caption that starts with "Notepad - " will be returned.
*
* @param pattern The caption pattern of the desired windows.
* @param ignoreCase Flags if case is significant in the caption pattern matches.
* @return The set top level windows with the specified caption text pattern.
*/
protected IWindow[] getTopWindowsWithCaptionPattern(String pattern, boolean ignoreCase)
{
Regex regex = ( ignoreCase ? new Regex(pattern, Regex. MATCH_CASEINDEPENDENT ) :
new Regex(pattern) );
java.util.Vector matches = new java.util.Vector(10);
IWindow[] topWindows = getTopWindows ();
int length = ( topWindows != null ? topWindows. length : 0 );
for ( int i = 0; i < length; ++i )
{
String text = topWindows[i].getText();
if ( regex.matches(text) )
matches.add(topWindows[i]) ;
}
int resultLength = matches.size();
IWindow[] result = ( resultLength != 0 ?
new IWindow[resultLength] :
null );
for ( int i = 0; i < resultLength; ++i )
result[i] = (IWindow)matches.elementAt(i);
return result;
}
相關文章
- 在RFT中查詢視窗中指定名稱的物件物件
- 根據經緯度座標查詢最近的門店
- 根據包名,在指定空間中建立物件物件
- 根據表查詢索引資訊索引
- 根據父表查詢子表
- 根據PID查詢 sqlSQL
- 指定快照時間內根據等待類查詢消耗較高的sqlSQL
- 在RFT中關閉所有IE瀏覽器視窗的3種方法瀏覽器
- Tkinter (20) 頂層視窗部件 Toplevel
- Laravel ORM 中,根據關聯查詢的欄位值,對主查詢排名LaravelORM
- Rafy 中的 Linq 查詢支援(根據聚合子條件查詢聚合父)
- 微博根據手機號查詢
- mybatis 根據多個id查詢資料 foreach標籤MyBatis
- Oracle查詢資料總數-根據count(主鍵),在ssh專案中Oracle
- 如何用 grep 命令在 UNIX 中根據檔案內容查詢檔案
- mysql like查詢 - 根據多個條件的模糊匹配查詢MySql
- linux根據字尾查詢文字Linux
- 根據欄位名查詢所有表
- 根據Tcode查詢Menu Path的Tcode
- pid,sid相互查詢,根據PID查詢sqlSQL
- windows 根據標題,關閉程式Windows
- linux 中根據檔案的大小進行檔案的查詢Linux
- JavaScript專題之學underscore在陣列中查詢指定元素JavaScript陣列
- 根據關鍵字查詢車輛資訊
- Oracle根據主鍵查詢外來鍵Oracle
- windows根據程式號查詢程式目錄Windows
- 根據TCode查詢User Exit and BADI
- vue+element-ui根據時間查詢VueUI
- 在AIX系統根據oracle程式pid查詢sql語句AIOracleSQL
- javascript設定層在視窗中垂直水平居中JavaScript
- 【資料】Arraylist中根據指定元素屬性排序排序
- 根據查詢條件批量修改表資料
- MyBatis-maven-User例子-根據id查詢UserMyBatisMaven
- mysql根據節點查詢所有葉節點MySql
- SQL server根據表名查詢表主鍵SQLServer
- 監聽視窗大小改變,同時根據視窗大小修改某個元素的大小
- jQuery實現元素根據視窗大小自適應效果jQuery
- 根據一個點獲取視窗控制程式碼的APIAPI