星期日, 7月 18, 2021

[Eggplant] 有效提升搜尋的準確度與速度

減少搜尋整個畫面是可以提升Eggplant Functional在搜尋目標(Text/Search)的速度,

可動態的去改變SearchRectangle的範圍即可。

以下記錄常用的方式


1. Eggplant官方文件提供的SearchRectangle的函式

function ScreenPart Portion


// Set up an easy-to-maintain property list that stores the necessary multipliers for the specified screen portion parameter value

set screenPortions to {

TopHalf: ((0,0),(1,.5)),

BottomHalf: ((0,.5),(1,1)),

LeftHalf: ((0,0),(.5,1)),

RightHalf: ((.5,0),(1,1)),

HorizontalMiddle: ((0,.25),(1,.75)),

VerticalMiddle:((.25,0),(.75,1)),

TopLeftQuadrant:((0,0),(.5,.5)),

TopRightQuadrant:((.5,0),(1,.5)),

BottomLeftQuadrant:((0,.5),(.5,1)),

BottomRightQuadrant:((.5,.5),(1,1)),

Center:((.25,.25),(.75,.75)),


}

set multiplier to screenPortions.(Portion) // Retrieves the value for the key in the property list. The name of the key is passed as a parameter into the function.

// Error handling is needed in the event that an unrecognized parameter is passed to the function

Log "Portion:"&&Portion

if multiplier is empty then

throw "Parameter error", Portion && "is not a recognized screen portion."

end if

return (the remoteScreenSize,the remotescreenSize) * multiplier

end ScreenPart



2. 透過圖片來指定SearchRectangle的範圍,如果畫面上遇到有重覆目標,但又想要搜尋單一目標可以使用以下方法

//鎖定搜尋範圍

put ImageLocation("iOS/CheckReservationInfo_Depatrue_Label_Rt_Left") into ULOfDepature

put ImageLocation("iOS/CheckReservationInfo_Depatrue_Label_Rt_Right") into BROfDepature

Log "設定搜尋範圍區塊-限去程ul/br"

set the SearchRectangle to [ULOfDepature,BROfDepature]



沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails