A Region is a rectangular area on a Screen.
A Region does not know anything about it’s visual content (windows, pictures, graphics, text, ...). It only knows the position on the screen and its dimension.
New Regions can be created in various ways:
• specify their position and dimension
• extend a given Region in all directions (expand or shrink)
• based on adjacent rectangles up to the bounds of the screen horizontally or vertically.
• based on their corners
class Region
Region(x, y, w, h)
Region(region)
Region(Rectangle)
Create a region object
Parameters
• x – x position of top left corner
• y – y position of top left corner.
• w – width of the region.
• h – height of the region.
• region – an existing Region object.
• rectangle – an existing object of class java.awt.Rectangle
Returns a new Region object.
Extending Region:
These methods return a new region object, that is based on the specified region (sometimes called spatial operators). The range parameter, if given as positive integer number, restricts the dimension of the new region (width and/or height respectively) to that value.
nearby([range ])
The new region is defined by extending (>0) or shrinking (<0) the current region’s dimensions in all
directions by range number of pixels. The center of the new region remains the same.
Parameters range – an integer indicating the number of pixels or the current default if omitted.
Returns a new Region object
above([range ])
below([range ])
left([range ])
right([range ])
Returns a new Region that is defined with respect to the given region:
•above: new bottom edge next pixel row above given region’s top edge
•below: new top edge next pixel row below given region’s bottom edge
•left: new right edge next pixel column left of given region’s left edge
•right: new left edge next pixel column right of given region’s right edge
Parameters range – a positive integer defining the new dimension aspect (width or height)
Returns a new Region object.
Example 1:
Example 1 Code:
FindReg3 = find("NewEntryBox.png")
Below = FindReg3.below()
Right = FindReg3.right()
display = Region(Below.getX(), Right.getY(), Right.getW(), Below.getH())
print display
display.highlight(3) # This region result will show in rectangle in red color.
print Below.getX() # 87
print Right.getY() # 111
print Right.getW() # 1186
print Below.getH() # 642
Example 2:
Example 2 Code:
FindReg7 = find(Pattern("HelpButton.png").similar(0.80))
Above = FindReg7.above()
Left = FindReg7.left()
display2 = Region(Left.getX(), Above.getY(), Left.getW(), Above.getH())
print display2
display2.highlight(3) # This region result will show in rectangle in red color.
print Left.getX() #0
print Above.getY() #0
print Left.getW() #564
print Above.getH() #639
Example 3:
Example 3 Code:
FindReg8 = find("EntryBlueBar.png")
Below = FindReg8.below()
Right = FindReg8.right()
display = Region(Below.getX(), Right.getY(), Below.getW()+Right.getW(), Below.getH()+Right.getH())
print display
display.highlight(3) # This region result will show in rectangle in red color.
print Below.getX() # 545
print Right.getY() # 103
print Below.getW() # 84
print Right.getW() # 737
print Below.getH() # 641
print Right.getH() # 24
Example for Find
Nearby:
find("1477685939643.png").nearby(50).find("1477685955906.png").highlight(3)
find("1477685939643.png").nearby(50).find("1477685955906.png").highlight(3)
Example for Find Left # test done in docs.seleniumhq.org
find("1477684805339.png").left(350).find("1477684837599.png").highlight(3)
Example for Find
Below # test done in docs.seleniumhq.org/download
find("Languae.png").below(150).find("Java-1.png").right(500).find("Download.png").highlight(3)
find("Languae.png").below(150).find("Java-1.png").right(500).find("Download.png").highlight(3)
Example for Find
Above # test done in docs.seleniumhq.org/download
find("Languae.png").below(250).find("1477685671961.png").right(700).find("1477685540801.png").above(150).find("1477685743514.png").highlight(3)
find("Languae.png").below(250).find("1477685671961.png").right(700).find("1477685540801.png").above(150).find("1477685743514.png").highlight(3)
No comments:
Post a Comment