Automated UI testing for Silverlight 4

Source: Internet
Author: User

Automated UI testing for Silverlight 4

Currently, Visual Studio 2010 SP1 has been released. You only need to install the Feature Pack 2 Patch package on this base to use the Coded UI Test to record the UI interface of Silverlight 4, and Playback your test case. Note that Feature Pack2 is useful for patching on the tested machine (MUT. Of course, you can install it on all machines.

Here we have a DLL file to note: Microsoft. VisualStudio. TestTools. UITest. Extension. SilverlightUIAutomationHelper. dll

This DLL is used to help the Coded UI Test identify the UI control of Silverlight 4. Note that it is referenced by the Silverlight program rather than the Test Project. Many friends may be confused at first.

The following is the recording result of BrowserWindow:

[GeneratedCode ("Coded UITest Builder", "10.0.40219.1")]
Public class UISilverlightApplicatiWindow: BrowserWindow
{

Public UISilverlightApplicatiWindow ()
{
# Region Search Criteria
This. SearchProperties [UITestControl. PropertyNames. Name] = "SilverlightApplication1 ";
This. SearchProperties [UITestControl. PropertyNames. ClassName] = "IEFrame ";
This. WindowTitles. Add ("SilverlightApplication1 ");
# Endregion
}

Public void LaunchUrl (System. Uri url)
{
This. CopyFrom (BrowserWindow. Launch (url ));
}

# Region Properties
Public UISilverlightApplicatiDocument
{
Get
{
If (this. mUISilverlightApplicatiDocument = null ))
{
This. mUISilverlightApplicatiDocument = new UISilverlightApplicatiDocument (this );
}
Return this. mUISilverlightApplicatiDocument;
}
}
# Endregion

# Region Fields
Private UISilverlightApplicatiDocument mUISilverlightApplicatiDocument;
# Endregion
}

The following is the HtmlDocument recording result:

[GeneratedCode ("Coded UITest Builder", "10.0.40219.1")]
Public class UISilverlightApplicatiDocument: HtmlDocument
{

Public UISilverlightApplicatiDocument (UITestControl searchLimitContainer ):
Base (searchLimitContainer)
{
# Region Search Criteria
This. SearchProperties [HtmlDocument. PropertyNames. Id] = null;
This. SearchProperties [HtmlDocument. PropertyNames. RedirectingPage] = "False ";
This. SearchProperties [HtmlDocument. PropertyNames. FrameDocument] = "False ";
This. FilterProperties [HtmlDocument. PropertyNames. Title] = "SilverlightApplication1 ";
This. FilterProperties [HtmlDocument. PropertyNames. AbsolutePath] = "/WebSite2/SilverlightApplication1TestPage.html ";
This. FilterProperties [HtmlDocument. PropertyNames. PageUrl] = "http: // localhost: 24805/WebSite2/SilverlightApplication1TestPage.html ";
This. WindowTitles. Add ("SilverlightApplication1 ");
# Endregion
}

# Region Properties
Public uisilverlightcontrolpolicane
{
Get
{
If (this. muisilverlightcontrolpolicane = null ))
{
This. muisilverlightcontrolpolicane = new uisilverlightcontrolpolicane (this );
}
Return this. muisilverlightcontrolpolicane;
}
}
# Endregion

# Region Fields
Private uisilverlightcontrolpolicane muisilverlightcontrolpolicane;
# Endregion
}

MainPage recording result of Silverlight:

[GeneratedCode ("Coded UITest Builder", "10.0.40219.1")]
Public class UIMainPageMainPage: SilverlightControl
{

Public UIMainPageMainPage (UITestControl searchLimitContainer ):
Base (searchLimitContainer)
{
# Region Search Criteria
This. SearchProperties [UITestControl. PropertyNames. ControlType] = "MainPage ";
This. WindowTitles. Add ("SilverlightApplication1 ");
# Endregion
}

# Region Properties
Public SilverlightText UITextBlockText
{
Get
{
If (this. mUITextBlockText = null ))
{
This. mUITextBlockText = new SilverlightText (this );
# Region Search Criteria
This. mUITextBlockText. SearchProperties [SilverlightText. PropertyNames. AutomationId] = "textBlock1 ";
This. mUITextBlockText. WindowTitles. Add ("SilverlightApplication1 ");
# Endregion
}
Return this. mUITextBlockText;
}
}
# Endregion

# Region Fields
Private SilverlightText mUITextBlockText;
# Endregion
}

In addition:

However, there is a problem here. For Data Mining spider, if the data source website uses silverlight but does not reference Microsoft. visual Studio. testTools. UITest. extension. silverlightUIAutomationHelper. dll, no matter whether it is data capture or Coded UI Test, there is no way to do it !!!

Can experts solve this problem?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.