在RFT中查詢視窗中指定名稱的物件

2021-08-25 00:12:23 字數 4354 閱讀 2853

"calc");

sleep (3);

iwindow parent = gettopwindowwithcaption(

"計算器"

,true);

parent.activate();

iwindow btn_1 = getchildwindowwithtext(parent,

"1",true,false);

btn_1.click();

iwindow btn_add = getchildwindowwithtext(parent,

"+",true,false);

btn_add.click();

btn_1.click();

iwindow btn_equal = getchildwindowwithtext(parent,

"=",true,false);

btn_equal .click();

gettopwindowwithcaption函式

根據指定的標題查詢頂層視窗。

getchildwindowwithtext函式如下,其作用是給定乙個視窗物件,查詢其中的指定名稱的物件:

/** *

given

aparticular

context,

find

achild

with

thespecified

text. *

typically

this

isused

tolocate

apushbutton

with

specific

text *

onit,

such

as"ok"

or"cancel". *

*@param

parent

thecontext

from

which

thesearch

isbased,

typically *

atop

level

window

like

adialog

box. *

@param

text

thetext

onthe

window

being

sought. *

@param

ignorecase

true

ifthe

case

ofthe

text

should

not *be

taken

into

consideration. *

@param

onlyimmediatechildren

true

ifthe

search

shouldbe

*limited

toonly

thechildren

ofthe

parent *

window

andnot

recurse

into

thegrandchildren .

*@return

thecontrol

with

thespecified

text

or

null

ifno *

child

with

thetext

islocated. */

publiciwindow getchildwindowwithtext(iwindow parent,

string text,

booleanignorecase,

booleanonlyimmediatechildren)

} returnnull; }

以下是支援正規表示式的版本:

/**

*given

aparticular

context,

find

achild

with

text

that

matches

the

*specified

regular

expression

pattern. *

typically

this

isused

tolocate

apushbutton

with

specific

text *

onit,

such

as"ok"

or"cancel"

when

theformat

ofthe

text

isnot

specific *

(for

instance

when

thetext

equals"ok

"insteadofa

******

"ok"). *

*@param

parent

thecontext

from

which

thesearch

isbased,

typically *

atop

level

window

like

adialog

box. *

@param

pattern

thepattern

forthe

text

onthe

window

being

sought. *

@param

ignorecase

true

ifthe

case

ofthe

text

should

not *be

taken

into

consideration. *

@param

onlyimmediatechildren

true

ifthe

search

shouldbe

*limited

toonly

thechildren

ofthe

parent *

window

andnot

recurse

into

thegrandchildren .

*@return

thecontrol

with

thespecified

text

or

null

ifno *

child

with

thetext

islocated. */

publiciwindow getchildwindowwithtextpattern(iwindow parent,

string pattern,

booleanignorecase,

booleanonlyimmediatechildren)

} returnnull; }

在父視窗中訪問iframe中的元素

用乙個簡單的例子來描述該問題 a.jsp頁面中 a frame src b.jsp frameborder 0 scrolling no b.jsp頁面中 指派班組負責人 現在需要在a頁面中修改用iframe嵌入的b.jsp頁面中的div的位置。實現方法如下 用document.frames a f...

在RFT中關閉所有IE瀏覽器視窗的3種方法

如果通過呼叫browser 測試物件的close 方法,則只能關閉乙個瀏覽器視窗 browser htmlbrowser close 要想關閉多個ie 瀏覽器視窗,可以通過殺死ie 程序的方式 try catch ioexception e 也可以通過查詢視窗名的方式來找到每個ie 視窗並關閉 iw...

Linq 中查詢乙個表中指定的字段

linq中查詢乙個表中指定的幾個字段 var ts t.findallitems where p p.companyid cursiteuser.companyid select s new distinct tolist orderbydescending s s.billperiod take ...