Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Threading.Tasks;
- using System;
- using System.CodeDom.Compiler;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Text.RegularExpressions;
- using System.Windows.Input;
- using Microsoft.VisualStudio.TestTools.UITest.Extension;
- using Microsoft.VisualStudio.TestTools.UITesting;
- using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;
- using Microsoft.VisualStudio.TestTools.UITesting.SilverlightControls;
- using Microsoft.VisualStudio.TestTools.UITesting.WinControls;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;
- using Mouse = Microsoft.VisualStudio.TestTools.UITesting.Mouse;
- using MouseButtons = System.Windows.Forms.MouseButtons;
- [CodedUITest]
- public class MyUi : SilverlightControl
- {
- [TestMethod]
- public void BasicCodedUiObjectModelTest()
- {
- BrowserWindow.Launch("http://localhost/DenSite/SmallSL01TestPage.html");
- SilverlightEdit uICalc1Edit = GetEditControl();
- uICalc1Edit.Text = "422f";
- Playback.Wait(10000);
- }
- private SilverlightEdit GetEditControl()
- {
- return browserWindow.SLDocument.SLDiv.SlCustom.SLControl.MyEditControl;
- }
- public IEWindow browserWindow {
- get {
- if ((mUISmallSL01InternetExpWindow == null)) {
- mUISmallSL01InternetExpWindow = new IEWindow();
- }
- return mUISmallSL01InternetExpWindow;
- }
- }
- private IEWindow mUISmallSL01InternetExpWindow;
- }
- public class IEWindow : BrowserWindow {
- // ctor not needed for the basic test...
- //public UISmallSL01InternetExpWindow()
- //{
- // #region Search Criteria
- // //this.SearchProperties[UITestControl.PropertyNames.Name] = "SmallSL01";
- // //this.SearchProperties[UITestControl.PropertyNames.ClassName] = "IEFrame";
- // //this.WindowTitles.Add("SmallSL01");
- // #endregion
- //}
- public SilverlightDocument SLDocument
- {
- get {
- mUISmallSL01Document = null; // debug
- if ((mUISmallSL01Document == null)) {
- mUISmallSL01Document = new SilverlightDocument(this);
- }
- return mUISmallSL01Document;
- }
- }
- private SilverlightDocument mUISmallSL01Document;
- } // UISmallSL01InternetExpWindow : BrowserWindow
- public class SilverlightDocument : HtmlDocument {
- public SilverlightDocument(UITestControl searchLimitContainer) :
- base(searchLimitContainer)
- {
- // this.SearchProperties[HtmlDocument.PropertyNames.Id] = null;
- // this.SearchProperties[HtmlDocument.PropertyNames.RedirectingPage] = "False";
- //this.SearchProperties[HtmlDocument.PropertyNames.FrameDocument] = "False";
- // this.FilterProperties[HtmlDocument.PropertyNames.Title] = "SmallSL01";
- //this.FilterProperties[HtmlDocument.PropertyNames.AbsolutePath] = "/DenSite/SmallSL01TestPage.html";
- //this.FilterProperties[HtmlDocument.PropertyNames.PageUrl] = "http://localhost/DenSite/xSmallSL01TestPage.html";
- this.WindowTitles.Add("SmallSL01");
- }
- public SilverlightDiv SLDiv
- {
- get
- {
- if ((mUISilverlightControlHoPane == null))
- {
- mUISilverlightControlHoPane = new SilverlightDiv(this);
- }
- return mUISilverlightControlHoPane;
- }
- }
- private SilverlightDiv mUISilverlightControlHoPane;
- }
- public class SilverlightDiv : HtmlDiv
- {
- public SilverlightDiv(UITestControl searchLimitContainer) :
- base(searchLimitContainer)
- {
- #region Search Criteria
- //this.SearchProperties[HtmlDiv.PropertyNames.Id] = "silverlightControlHost";
- //this.SearchProperties[HtmlDiv.PropertyNames.Name] = null;
- //this.FilterProperties[HtmlDiv.PropertyNames.InnerText] = null;
- //this.FilterProperties[HtmlDiv.PropertyNames.Title] = null;
- //this.FilterProperties[HtmlDiv.PropertyNames.Class] = null;
- //this.FilterProperties[HtmlDiv.PropertyNames.ControlDefinition] = "id=\"silverlightControlHost\"";
- //this.FilterProperties[HtmlDiv.PropertyNames.TagInstance] = "1";
- //this.WindowTitles.Add("SmallSL01");
- #endregion
- }
- public SilverlightCustom SlCustom
- {
- get
- {
- if ((this.mUIItemCustom == null))
- {
- this.mUIItemCustom = new SilverlightCustom(this);
- }
- return this.mUIItemCustom;
- }
- }
- private SilverlightCustom mUIItemCustom;
- } //UISilverlightControlHoPane : HtmlDiv
- public class SilverlightCustom : HtmlCustom
- {
- public SilverlightCustom(UITestControl searchLimitContainer) :
- base(searchLimitContainer)
- {
- //this.SearchProperties["TagName"] = "OBJECT";
- //this.SearchProperties["Id"] = null;
- //this.SearchProperties[UITestControl.PropertyNames.Name] = null;
- //this.FilterProperties["Class"] = null;
- //this.FilterProperties["ControlDefinition"] = "width=\"100%\" height=\"100%\" data=\"data:ap";
- //this.FilterProperties["TagInstance"] = "1";
- //this.WindowTitles.Add("SmallSL01");
- }
- public SilverlightUtilityControl SLControl
- {
- get
- {
- if ((this.mUIMainPageMainPage == null))
- {
- this.mUIMainPageMainPage = new SilverlightUtilityControl(this);
- }
- return this.mUIMainPageMainPage;
- }
- }
- private SilverlightUtilityControl mUIMainPageMainPage;
- } //UIItemCustom : HtmlCustom
- public class SilverlightUtilityControl : SilverlightControl
- {
- public SilverlightUtilityControl(UITestControl searchLimitContainer) :
- base(searchLimitContainer)
- {
- // This next line must be present - comment it out to see the Coded UI failures
- this.SearchProperties[UITestControl.PropertyNames.ControlType] = "MainPage";
- //this.WindowTitles.Add("SmallSL01");
- }
- public SilverlightEdit MyEditControl {
- get
- {
- mmahEdit = null; //debug
- if ((this.mmahEdit == null))
- {
- // The next line must be present...
- mmahEdit = new SilverlightEdit(this);
- // The next line must reference a control - break the name to see the error
- this.mmahEdit.SearchProperties[SilverlightEdit.PropertyNames.AutomationId] = "Calc1";
- //this.mmahEdit.WindowTitles.Add("SmallSL01");
- }
- return this.mmahEdit;
- }
- }
- private SilverlightEdit mmahEdit;
- } // UIMainPageMainPage : SilverlightControl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement