I m trying to do some automation tests in 1 application using TestStack.White framework , and i can t find a solution on how to click on a hyperlink located in one Document. document.logstructure() :
AutomationId: linkTexts
ControlType: ControlType.Document
Name: Perform an action on event#LinkId=1
from devices/recording server/management server#LinkId=2
HelpText:
Bounding rectangle: 354,563,570,151
ClassName: WindowsForms10.RichEdit20W.app.0.ca490a_r12_ad1
IsOffScreen: False
FrameworkId: WinForm
ProcessId: 6816
System.Windows.Automation.ScrollPattern
System.Windows.Automation.TextPattern
UISpy : UISpy view
And pic of hyperlink: Picture of hyperlink located in app
Thank you !
After days of searching , the best solution I could find is this:
{
...
//Get document container
var document = _modalWindow.Get(SearchCriteria.ByAutomationId(Config.DocumentRulesEvent));
// Get document's bounding Rectangle
string rightCorner = document.Bounds.Right.ToString();
string leftCorner = document.Bounds.Left.ToString();
string topCorner = document.Bounds.Top.ToString();
string bottomCorner = document.Bounds.Bottom.ToString();
// Hardcoded percent of x and y
int percentX = 22;
int percentY = 7;
GetCoordinatesFromBoundingRectangle(rightCorner, leftCorner, topCorner, bottomCorner, percentX, percentY);
}
public void GetCoordinatesFromBoundingRectangle(string rightCorner, string leftCorner, string topCorner, string bottomCorner, int percentX, int percentY)
{
// transform strings to integre
int a = Int32.Parse(rightCorner);
int b = Int32.Parse(leftCorner);
int c = Int32.Parse(topCorner);
int d = Int32.Parse(bottomCorner);
// Calculate X from AB segment
int x = (a - b) * percentX;
x = x / 100;
x = b + x;
//Calculate Y from CD segment
int y = (d - c) * percentY;
y = y / 100;
y = c + y;
ClickOnPoint(x, y);
}
// Method that moves mouse to x and y and click
public void ClickOnPoint(int x, int y)
{
var pointClick = new System.Windows.Point(x, y);
Mouse.Instance.Click(MouseButton.Left, pointClick);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.