How to programmatically "Click" Silverlight HyperlinkButton (WebAii)

I am currently using the WebAii automation environment to write some user interface tests in a Silverlight 3 application. I am new to Silverlight and suspect that I am missing information on HyperlinkButton.

There is HyperlinkButton in the application, and I try to write code that moves to the page, finds a button on the page, then “clicks” this button (which then goes to NavigateUri, as indicated in the HyperlinkButton properties).

I can’t figure out how to execute this click. Code I still have (simplified):

Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
ActiveBrowser.NavigateTo("http://server/appname/");
var slApp = ActiveBrowser.SilverlightApps()[0];
var menu = slApp.FindName<StackPanel>("LinksStackPanel");
var linkicareabout = menu.Find.ByName<HyperlinkButton>("Some Cases");

I expect to see some Click () action or the Navigate () method that I could call in the "linkicareabout" variable, but I have to skip how to do this.

+3
source share
2 answers

What you are looking for is a User object with a hyperlink. All controls that WebAii works with have this object. Thus, you can invoke any user action for any type of control.

<code> linkicareabout.User.Click () Code>

The User object supports any user actions that you can think of and simulate real user interactions. Check out the documentation here .

+3
source

. Firefox IE HtmlPage.Window.Navigate URL.

Safari Chrome . HTML- javascript.

.

, HTML-, Silverlight, DOM.

 HtmlElement anchor = HtmlPage.Document.GetElementById("externalAnchor");
 HtmlElement button = HtmlPage.Document.GetElementById("externalButton");
 if ((anchor != null) && (button != null))
 {
     anchor.SetProperty("href", url);
     button.Invoke("click", null);
 }
+2

Source: https://habr.com/ru/post/1716337/


All Articles