GithubHelp home page GithubHelp logo

icnocop / cuite Goto Github PK

View Code? Open in Web Editor NEW
52.0 14.0 29.0 15.26 MB

Coded UI Test enhanced Framework

License: Microsoft Public License

C# 98.58% HTML 0.36% Batchfile 0.06% Gherkin 0.22% PowerShell 0.78% JavaScript 0.01%

cuite's Introduction

Build Status

What is CUITe?

CUITe (Coded UI Test enhanced) Framework is a thin layer developed on top of Microsoft Visual Studio Team Test's Coded UI Test engine which helps reduce code, increases readability and maintainability, while also providing a bunch of cool features for the automation engineer.

Supported technologies

  • HTML
  • WPF
  • WinForms
  • Silverlight

Supported Visual Studio versions

  • Visual Studio 2010 Ultimate or Premium with Feature Pack 2
  • Visual Studio 2012 Ultimate or Premium
  • Visual Studio 2013 Ultimate or Premium
  • Visual Studio 2015 Enterprise
  • Visual Studio 2017 Enterprise
  • Visual Studio 2019 Enterprise
  • Visual Studio 2022 Enterprise

Installation

Install CUITe using NuGet and make sure you include prerelease packages.

Install CUITe using the NuGet Package Manager

If your intent is to test HTML you might also want to install Selenium components for Coded UI Cross Browser Testing.

The NuGet package to install depends on the Visual Studio version you are using.

CUITe in Visual Studio 2010

Installing CUITe for HTML, WPF and WinForms:

Install-Package CUITe.VS2010 -Pre

Install CUITe for Silverlight:

Install-Package CUITe.Silverlight.VS2010 -Pre

CUITe in Visual Studio 2012

Installing CUITe for HTML, WPF and WinForms:

Install-Package CUITe.VS2012 -Pre

Install CUITe for Silverlight:

Install-Package CUITe.Silverlight.VS2012 -Pre

You should also install the extension Microsoft Visual Studio 2012 Coded UI Test Plugin for Silverlight.

CUITe in Visual Studio 2013

Installing CUITe for HTML, WPF and WinForms:

Install-Package CUITe.VS2013 -Pre

Install CUITe for Silverlight using the NuGet Package Manager:

Install-Package CUITe.Silverlight.VS2013 -Pre

You should also install the extension Microsoft Visual Studio 2013 Coded UI Test Plugin for Silverlight.

CUITe in Visual Studio 2015

Installing CUITe for HTML, WPF and WinForms:

Install-Package CUITe.VS2015 -Pre

Install CUITe for Silverlight using the NuGet Package Manager:

Install-Package CUITe.Silverlight.VS2015 -Pre

You should also install the extension Microsoft Visual Studio 2015 Coded UI Test Plugin for Silverlight.

CUITe in Visual Studio 2017

Installing CUITe for HTML, WPF and WinForms:

Install-Package CUITe.VS2017 -Pre

Install CUITe for Silverlight using the NuGet Package Manager:

Install-Package CUITe.Silverlight.VS2017 -Pre

You should also install the extension Unofficial Microsoft Visual Studio 2017 Coded UI Test Plugin for Silverlight.

CUITe in Visual Studio 2019

Installing CUITe for HTML, WPF and WinForms:

Install-Package CUITe.VS2019 -Pre

Install CUITe for Silverlight using the NuGet Package Manager:

Install-Package CUITe.Silverlight.VS2019 -Pre

You should also install the extension Unofficial Microsoft Visual Studio 2019 Coded UI Test Plugin for Silverlight.

CUITe in Visual Studio 2022

Installing CUITe for HTML, WPF and WinForms:

Install-Package CUITe.VS2022 -Pre

Install CUITe for Silverlight using the NuGet Package Manager:

Install-Package CUITe.Silverlight.VS2022 -Pre

You should also install the extension Unofficial Microsoft Visual Studio 2022 Coded UI Test Plugin for Silverlight.

Using CUITe

As best practice, we recommend writing object repositories for a more object-oriented approach to testing. Object repositories can more easily be created using the object recorder instead of manually creating them for HTML web pages. For more information see Recording objects using the CUITe Object Recorder or more code examples here.

Here are simple examples of testing filling out a form:

HTML

// Launch the web browser and navigate to the homepage
BrowserWindowUnderTest browserWindow = BrowserWindowUnderTest.Launch("https://website.com");

// Enter the first name
browserWindow.Find<HtmlEdit>(By.Id("FirstName")).Text = "John";

// Enter the last name
browserWindow.Find<HtmlPassword>(By.Id("LastName")).Text ="Doe";

// Click the Save button
browserWindow.Find<HtmlInputButton>(By.Id("Save")).Click();

WPF

// Launch the application
ApplicationUnderTest.Launch(@"C:\path to your application.exe");

// Find the main window of your application
WpfWindow window = new WpfWindow(By.Name("Main Window Title"));

// Enter the first name
window.Find<WpfEdit>(By.Name("FirstName")).Text = "John";

// Enter the last name
window.Find<WpfEdit>(By.Name("LastName")).Text = "Doe";

// Click on the Save button
window.Find<WinButton>(By.Name("Save")).Click();

WinForms

// Launch the application
ApplicationUnderTest.Launch(@"C:\path to your application.exe");

// Find the main window of your application
WinWindow window = new WinWindow(By.Name("Main Window Title"));

// Enter the first name
window.Find<WinEdit>(By.Name("FirstName")).Text = "John";

// Enter the last name
window.Find<WinEdit>(By.Name("LastName")).Text = "Doe";

// Click on the Save button
window.Find<WinButton>(By.Name("Save")).Click();

Silverlight

// Launch the browser where the silverlight application is hosted
BrowserWindowUnderTest browser = BrowserWindowUnderTest.Launch("https://website.com");

// Enter the first name
browser.Find<SilverlightEdit>(By.AutomationId("FirstName")).Text = "John";

// Enter the last name
browser.Find<SilverlightEdit>(By.AutomationId("LastName")).Text = "Doe";

// Click on the Save button
browser.Find<SilverlightButton>(By.AutomationId("Save")).Click();

Recording objects using the CUITe Object Recorder

The CUITe Object Recorder supports recording objects from an HTML web page only.

  1. Launch the CUITe Object Recorder from the location where the NuGet package was installed.

    For example, launch /packages/CUITe.VS2013.x.x.x/tools/CUITe_ObjectRecorder.exe, relative to your solution.

  2. Enter the full address of your web page in the Address field (ex. http://website.com).

  3. Click on the 'Record' button.

  4. Click on the objects you want to record actions against.

  5. Click on the 'Code' button.

  6. Copy the code and paste it in a new file in your Coded UI Test project.

  7. Change the placeholder '$ProjectNameSpace$' with your namespace.

  8. Use the class and generated code in a more object-oriented fashion:

// Launch the web page
MyObjectRepository browserWindow = BrowserWindowUnderTest.Launch<MyObjectRepository>("https://website.com");

// Enter the first name
browserWindow.FirstName.Text = "John";

// Enter the last name
browserWindow.LastName.Text ="Doe";

// Click on the Save button
browserWindow.Save.Click();

Contact

Join the chat at https://gitter.im/icnocop/cuite

cuite's People

Contributors

ankisaxena avatar fantasticfiasco avatar gitter-badger avatar icnocop avatar thepantz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cuite's Issues

Unable to run cuite test locally from Visual Studio 2013 on Win 10 machine

I have a coded ui solution containing coded ui tests, whenever i try to run or debug any test from VS 2013 i get the below error in test explorer-

Unit Test Adapter threw exception: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information..

I'm using Visual studio 2013 ultimate edition, Win 10 machine. Any help in resolving the issue is highly appreciated.

Consolidate solutions and projects

There are far to many solutions and projects in the source code, and synchronizing these is error prone.

When it comes to the solution I think the maintainer should decide on one Visual Studio version. I would propose Visual Studio 2013, and if no major bug is discovered in the upcoming month in Visual Studio 2015, move over to that version.

Regarding the projects I think the maintainer can use different project configurations to decide which .NET version to target. I've done so to MVVM Dialogs with great success.

Blocking control exception due to page longer than browser window

I have looked at codeples, the interweb and git issues, but could not find an answer.

We have a number of web pages longer than the browser window. When using CodedUI, we would have to press the page down button to expose the controls, or else we would get an exception with "Another control is blocking the control". A brittle solution.

We are wanting to use the page object pattern and putting PageDown sendkeys in the object not is only brittle, but ties the page to the browser.

What is the suggested method for exposing HTML controls for web pages that are longer/bigger than the browser window?

thanks

Add support for the "ControlId" search property/configuration

Add support for the "ControlId" search property/configuration.

In CUITe v1.0.6, I could specify "ControlId=12345" as a search property, but in v2.0.265 I get the following compilation error:

CS0117 'By' does not contain a definition for 'ControlId'

Decide on license

You need to decide on a license for this project. GitHub can propose licenses for you depending on your wishes, but the easiest thing to do would be to select the same license for the GitHub code as you had for the code on CodePlex.

I you didn't have any license on CodePlex, now is your chance to select the appropriate for the project.

Add support for the "ClassName" search property/configuration

Add support for the "ClassName" search property/configuration.

In CUITe v1.0.6, I could specify "ClassName=#32770" as a search property, but in v2.0.265 I get the following compilation error:

CS0117 'By' does not contain a definition for 'ClassName'

CUITe tests not discovered in VS2015

Tests are not running in VS2015, I have included the "specific version" of the testing DLLs from successful runs in VS2012. Tests seem discovered, but are not running with the following in the output window:

There is no test with the specified Id (guid listed)

An additional issue that appears to occur when I do not copy over the specific UnitTesting dlls from VS2012's versions of the test DLLs is:

Warning: Unable to load types from the test source 'H:\Test***.dll'. Some or all of the tests in this source may not be discovered. If you are running unit tests for Windows Store apps and referencing custom WinMD type then please visit http://go.microsoft.com/fwlink/?LinkId=238340 for more info. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'M
icrosoft.VisualStudio.TestTools.UITesting, Version=11.0.0.0, Culture=neutral, Pu
blicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot fin
d the file specified.
.
Warning: MSTestAdapter failed to discover tests in class 'SmokeTest.CodedUITest1' of assembly 'H:\Test**
*.dll'. Reason Could not load file or assembly Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified..

I'm assuming this is due to CUITe being targeted at specific microsoft unit testing DLLs and CUITe has not yet been given build steps/definition for VS2015's version of said DLLs? Only guessing there, I really have no idea what I'm talking about :O.

HtmlControl.GetChildren() returns objects with insufficent search properties?

I haven't used CUIT or CUITe much so I might have misunderstood this. But lately I run into this problem (simplified example).

In the web page there is a part that has something that looks like follows:

<div>
  <p>1</p>
  <p>2</p>
  <p>3</p>
  <p>4</p>
  <p>5</p>
  <p>6</p>
</div>

Variable item is set by locating the DIV by using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDiv.
Then I use it to locate all its children.

HtmDiv panel = new HtmlDiv((UITesting.HtmlControls.HtmlDiv)item);
IEnumerable<CUITe.Controls.ControlBase> controls = panel.GetChildren();
foreach (var ctrl in controls)
 {
    if (ctrl is HtmlParagraph)
    {
      HtmlParagraph p = (HtmlParagraph)ctrl;
      TestContext.WriteLine("p = {0}", p.InnerText);
   }
 }

The result is

p = 1
p = 1
p = 1
p = 1
p = 1
p = 1

I made a copy of the GetChildren and WrapUtil methods in HtmlControls in my own code and debugged WrapUtil. I noticed that WrapUtil in turn gets the six paragraphs as expected. But the returned HtmlParagraph objects all look the same. As I understand UITesting doesn't locate a control until you try to fetch something from it. So when p.InnerText evaluates it always finds and returns the first P-element since the only search property is TagName = "P".

I made a try to modify WrapUtil as this to see if I could get a more precise search specification

   private static CUITe.Controls.ControlBase WrapUtil(CUITControls.HtmlControl sourceControl)
    {
        CUITe.Controls.ControlBase control;

        string searchProperty = String.Format("TagInstance={0}", sourceControl.TagInstance);
        ...
        switch (sourceControl.TagName.ToLower())
                        {
                            case "p":
                                control = new HtmlParagraph((CUITControls.HtmlCustom)sourceControl, By.SearchProperties(searchProperty));
                                break;

Well it worked for the first two returned children. Then it failed for the third child with

Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: 
The playback failed to find the control with the given search properties. 
Additional Details: 
TechnologyName:  'Web'
TagInstance:  '7'
TagName:  'p'
MaxDepth:  '1'
Instance:  '2'

Is this anyway around this or must I solve it myself by switching to only use Microsoft's UITesting?

I used Coded UI Test Builder to see how it would specify the search properties:

  this.mUIItemCustom1 = new HtmlCustom(this);
  this.mUIItemCustom1.SearchProperties["TagName"] = "P";
  this.mUIItemCustom1.SearchProperties["Id"] = null;
  this.mUIItemCustom1.SearchProperties[UITestControl.PropertyNames.Name] = null;
  this.mUIItemCustom1.FilterProperties["Class"] = null;
  this.mUIItemCustom1.FilterProperties["ControlDefinition"] = null;
  this.mUIItemCustom1.FilterProperties["TagInstance"] = "6";

So I started to think if a

HtmlControl.GetChildren(string filterProperties)

where you specify which properties of the sourceControl to use as filterProperties on the new control. For instance like this

HtmDiv panel = new HtmlDiv((UITesting.HtmlControls.HtmlDiv)item);
IEnumerable<CUITe.Controls.ControlBase> controls = panel.GetChildren("TagInstance");
foreach (var ctrl in controls)
 {
    if (ctrl is HtmlParagraph)
    {
      HtmlParagraph p = (HtmlParagraph)ctrl;
      TestContext.WriteLine("p = {0}", p.InnerText);
   }
 }

Not sure whether it solves the problem or not but would give one the possibility to also filter amongst matching controls.

Expand component modeling

I wasn't sure how else to reach you, but I wish I had noticed you updated the CUITe to include new types. I also spent time last year creating CodedUI Fluent Extensions because I didn't realize this project existed at the time. The primary purpose for creating that was to enhance the modeling system and abstract away the underlying technology into behavior such as clicking and setting values. You have some abstraction around ViewComponents and such, but I would like to bring in some of the page modeling stuff to CUITe.

I'm going to do a small implementation of my page modeling interfaces using CUITe to see if that's something you'd be interested in pulling into the project.

How to get one page object from another?

Hi, is it possible to instantiate somehow one page object from another (on the "same levels" of UI control tree)?

Here is the example structure:

<div id="A">
  <div id="B"></div>
  <div id="C"></div>
</div>

So I have a Page class with the method that returns me a page object for the div B. How can I get page object for the div C from it?

To clarify the situation lets suppose that divB is a button and divC is a related confirmation dialog - that's why I want to get page object for the divC only from the particular page object and not from the class that describes the whole page.

CUITe.Controls.InvalidSearchPropertyNamesException. Class instead of ClassName

Weirdly enough, I get the InvalidSearchPropertyNamesException whenever I try to find a WPF element using its class name.

Find<WpfMenu>(By.ClassName(ContextMenuClassName))

It says that the 'Class' property is not supported and then lists the supported properties among which there is a ClassName.

Maybe there is something different between adding search properties to the WpfMenu element (the one I'm currently having problems with) and to the UITestControl (this one is used in the ClassNameConfigurator class)?

Coded UI autogenerated test works fine.

I got CUITe.VS2013 2.0.282-beta

Preparation for 2.0 release

The following items have to be addressed before releasing CUITe 2.0:

  • Remove Pre from NuGet package
  • Perhaps mentioning the prerequisites in the NuGet description to prevent developers to install the package when they are using the wrong version or edition of Visual Studio.
  • Perhaps open a readme describing the prerequicites after NuGet is installed, i.e. the extra requirements for HTML and Silverlight testing
  • Create a complete Wiki describing the state of 2.0
  • Create a document where we describe the changes (new features, bug fixes and so on) between each version DONE

Anything else you can think of?

How to extend CUITe controls?

I'd like to extend the CUITe controls to support certain properties of a Custom control that are present in our application without changing the CUITe source code. For example how to create a new class that would extend the CUITe.Controls.SilverlightControls.SilverlightComboBox to either override some of the methods or add new methods to handle certain functionalities of a custom control while providing the access to the existing methods and properties for the base class in CUITe. I'd greatly appreciate a small working sample. I did try to create a new class that inherits from the CUITe SilverlightComboBox but when trying to use 'Find' and 'By' to define a ComboBox control I get the following error: System.ArgumentException: No constructor for type 'CUITe.Controls.SilverlightControls.Custom.SilverlightComboBox' contains arguments in the following order:

  1. By - Search configuration

Extend WPF and WinForms tests

Before making my main contributions to the project (regarding screen objects and screen components) I would like to extend the WPF and WinForms test. With a large battery of unit tests I can make changes to CUITe and still be confident that the changes didn't break any functionality.

Port readme.txt to README.md

GitHub heavily relies in the README.md. Port the text from readme.txt to README.md. MD is short for Markdown and here is a good introduction to its syntax.

Build for VS 2015 Enterprise?

I've downloaded and installed the "default" CUITe (with no version specification). I noticed that it's an older build than the others (like CUITe.VS2013) but I guess the one to use for VS 2015.

If so I've a problem with HtmlTable in CUITe. Using the following construction in my code

HtmlCell cell = table.GetCell(i, j);

I get the following exception:
The type 'CUITe.Controls.HtmlControls.HtmlCell' contains no public constructor with the following arguments:
1. Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlHeaderCell
2. CUITe.SearchConfigurations.By

For some reason it tries to construct a new HtmlHeaderCell instead of a new HtmlCell. An error in the package?

Fix tests in 'CUITe for .NET v4.5 (VS2013)' solution

There are tests failing in the solution called CUITe for .NET v4.5 (VS2013). I will fix the once relating to WPF but there are about 19 tests that fail in Sample_CUITeTestProject. I can only assume that I haven't got the same environment as you do? Are we running the tests on different versions of IE?

Can you verify that the tests work on your machine?

Name of controls

I would really love to change the prefix of the controls from CUITe to Enhanced. It means for instance that CUITe_HtmlButton would be called EnhancedHtmlButton.

I realize that renaming all controls would break backward compatibility, and I realize the severity of it. But the current naming format with using the prefix CUITe with the underscore after is looking rather odd in C# and is breaking Microsoft guidelines.

In the General Naming Conventions section one can read:
DO NOT use underscores, hyphens, or any other nonalphanumeric characters.
DO NOT use any acronyms that are not widely accepted, and even if they are, only when necessary.

What is your take on the issue?

Trouble getting instance of Object Repository from BrowserWindowUnderTest

I'm sure I'm doing this incorrectly, but I'm not finding a whole lot on a tutorial on how to go about accomplishing a multi page test. I had this working previous with the older syntax (codeplex's version) but am having trouble with the current syntax.

public class Foo
{
    public void System_Login(string URL, string UserID, string Password, string System)
    {
        BrowserWindow bw = BrowserWindowUnderTest.Launch(URL);
        LogInPage pgLogin = BrowserWindowUnderTest.GetBrowserWindow<LogInPage>();
        pgLogin.txtUserID.Text = UserID;
        pgLogin.txtPassword.Text = Password;
        pgLogin.cboSystem.SelectItem(System);
        pgLogin.btnLogin.Click(); // Directs to "NewPage"

        DoStuff();
    }

    public void DoStuff()
    {
         NewPage newPage = BrowserWindowUnderTest.GetBrowserWindow<NewPage>();
    }
}

public class LogInPage : BrowserWindowUnderTest
{
    public LogInPage() : base("Log-In Page")
    {
    }

    public HtmlEdit txtUserID
    {
        get
        {
            return this.Find<HtmlEdit>(By.Id("text1"));
        }
    }
    public HtmlPassword txtPassword
    {
        get 
        {
            return this.Find<HtmlPassword>(By.Id("password1"));
        }
    }
    public HtmlComboBox cboSystem
    {
        get
        {
            return this.Find<HtmlComboBox>(By.Id("cboSystem"));
        }
    }
    public HtmlInputButton btnLogin
    {
        get
        {
            return this.Find<HtmlInputButton>(By.Id("submit1"));
        }
    }

}

I get a successful compile, but I'm getting an exception when attempting to resolve my LoginPage from LogInPage pgLogin = BrowserWindowUnderTest.GetBrowserWindow<LogInPage>();

The exception is:

Test Name: SmokeTest_DEV
Test Outcome: Failed
Result Message:
Test method SmokeTest.CodedUITest1.SmokeTest_DEV threw exception:
System.MissingMethodException: Constructor on type 'SmokeTest.ObjectRepository.LogInPage' not found.
Result StandardOutput:
Debug Trace:
V, 2888, 14, 2015/12/30, 11:56:29.406, 2335822818100, QTAgent32.exe, ConstructDeviceToDriveMap() Added mapping '\Device\Mup' -> ''
V, 2888, 14, 2015/12/30, 11:56:29.406, 2335822818743, QTAgent32.exe, ConstructDeviceToDriveMap() Added mapping '\Device\RdpDr' -> ''
V, 2888, 14, 2015/12/30, 11:56:29.406, 2335822819210, QTAgent32.exe, ConstructDeviceToDriveMap() Added mapping '\Device\LanmanRedirector' -> ''
V, 2888, 14, 2015/12/30, 11:56:29.406, 2335822819692, QTAgent32.exe, ConstructDeviceToDriveMap() Added mapping '\Device\WebDavRedirector' -> ''
V, 2888, 14, 2015/12/30, 11:56:29.406, 2335822824667, QTAgent32.exe, ConstructDeviceToDriveMap() Added mapping '\Device\HarddiskVolume2' -> 'C:'
V, 2888, 14, 2015/12/30, 11:56:29.406, 2335822825430, QTAgent32.exe, ConstructDeviceToDriveMap() Added mapping '\Device\CdRom0' -> 'D:'
V, 2888, 14, 2015/12/30, 11:56:29.406, 2335822825960, QTAgent32.exe, ConstructDeviceToDriveMap() Added mapping '\Device\HarddiskVolume3' -> 'F:'
V, 2888, 14, 2015/12/30, 11:56:29.406, 2335822826635, QTAgent32.exe, ConstructDeviceToDriveMap() Added mapping '\Device\LanmanRedirector;G:0000000000b2612a\DEVFILE\vol3\Data\Common' -> 'G:'
V, 2888, 14, 2015/12/30, 11:56:29.406, 2335822827474, QTAgent32.exe, ConstructDeviceToDriveMap() Added mapping '\Device\LanmanRedirector;H:0000000000b2612a\devfile\vol3\Home\Rhammett' -> 'H:'
V, 2888, 14, 2015/12/30, 11:56:30.250, 2335825860170, QTAgent32.exe, ExtensionFramework : Assembly resolver trying to resolve Microsoft.VisualStudio.TestTools.UITest.Extension.IE.EventHelper
V, 2888, 14, 2015/12/30, 11:56:30.250, 2335825863176, QTAgent32.exe, ExtensionFramework : Assembly resolver trying to resolve Microsoft.VisualStudio.TestTools.UITest.Extension.IE.EventHelper

Is my syntax wrong? Am I doing something else wrong? My LoginPage does have a public parameterless constructor, not sure why it's throwing an exception on attempting to assign my LoginPage var

Obsolete methods

There are some methods that are marked as obsolete, for instance in BrowserWindowUnderTest. Do you have any plans when we can remove those? Would it be appropriate for me to remove them during my refactoring of the ControlBase classes?

Not able to limit searching for a control to a specific Screen

The anomaly I noticed is that if the parent Screen has an "OK" button and the modal dialog has an "OK" button, I can't be certain the correct one will be found when trying to search for the control by its name because the NavigateTo<T> method doesn't seem to limit the search specifically to the child dialog.

Steps to reproduce:

  1. Edit .\src\SystemsUnderTest\Sut.Wpf.ScreenObjects\MainWindow.xaml:
    a. Append <RowDefinition /> within the <Grid.RowDefinitions>
    b. Add <Button Grid.Row="3" Content="OK"></Button> before </Grid>

  2. Edit .\src\SystemsUnderTest\Sut.Wpf.ScreenObjects\Dialog.xaml:
    Add <Button Content="OK"/> before </StackPanel>

  3. Add the following property to .\src\SystemsUnderTest\Sut.Wpf.ScreenObjectsTest\ScreenObjects\DialogScreen.cs:

    public WpfButton OkButton
    {
        get { return Find<WpfButton>(By.Name("OK")); }
    }
    
  4. Add the following test to .\src\SystemsUnderTest\Sut.Wpf.ScreenObjectsTest\ScreenComponentsTest.cs:

    [TestMethod]
    public void ClickOkButtonInChildDialog()
    {
        // Act
        var dialogScreen = mainScreen.MiddleScreenObject.NavigateToModalDialogScreen();
    
        dialogScreen.OkButton.DrawHighlight();
    
        // Assert
        dialogScreen.OkButton.Click();
    }
    
  5. Run the ClickOkButtonInChildDialog test method and observe that the "OK" button on the parent dialog is highlighted and clicked.

I expected the "OK" button on the child dialog to get highlighted and clicked.

I'm wondering if the NavigateTo<T>() should allow passing in search properties (and a window title). In this way, if there are multiple dialogs visible the search properties will help identify which specific dialog the subsequent code should be interacting with.

As a side note, I would have liked to be able to call dialogScreen.DrawHighlight(); (or something equivalent).

Thank you.

Check control's visibility

Hey guys!
I'd like to add several new members to the ControlBase class to have an ability to work with control's visibility.

Please see this page.

In total, I'm suggesting to add three new members to the ControlBase class:

        /// <summary>
        /// Gets a value indicating whether this element is visible in the user interface.
        /// </summary>
        public bool Visible
        {
            get
            {
                Point clickablePoint;
                return sourceControl.TryGetClickablePoint(out clickablePoint);
            }
        }

        /// <summary>
        /// Waits for the control to become visible in the user interface.
        /// </summary>
        /// <returns><code>true</code> if this control is visible before the time-out; otherwise, <code>false</code>.</returns>
        public bool WaitForControlVisible()
        {
            Point clickablePoint;
            return sourceControl.WaitForControlCondition(control => control.TryGetClickablePoint(out clickablePoint));
        }

        /// <summary>
        /// Waits for the control to become visible in the user interface, or for the specified timeout to expire.
        /// </summary>
        /// <param name="millisecondsTimeout">The number of milliseconds before time-out.</param>
        /// <returns><code>true</code> if this control is visible before the time-out; otherwise, <code>false</code>.</returns>
        public bool WaitForControlVisible(int millisecondsTimeout)
        {
            Point clickablePoint;
            return sourceControl.WaitForControlCondition(control => control.TryGetClickablePoint(out clickablePoint), millisecondsTimeout);
        }

What do you think?

No class for HTML <strong> tag?

The previous version had the class CUIT_HtmlStrong. In version 2, I don't see an HtmlStrong class. Has this functionality been removed, or relocated?

Can't find controls in a wpf window

My platform: WIn 10 Pro x64, VS 2013 Ultimate Update 5

Main project with the app:

MainWindow.xaml

<Window  x:Class="TestWpfApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="164" Width="256" Name="TestWpfApplication">
    <Grid VerticalAlignment="Top">
        <StackPanel Margin="8">
            <TextBox Name="FirstNameTextBox" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Text="First Name"/>
            <TextBox Name="LastNameTextBox" Height="23" Margin="0,8" TextWrapping="Wrap" Text="Last Name" VerticalAlignment="Top" Width="120"/>
            <Button Name="GreetingsButton"  Content="Say Hey!" VerticalAlignment="Top" Width="75" Margin="0,0,0,8" Click="Button_Click"/>
            <TextBlock Name="GreetingsTextBlock" TextAlignment="Center" TextWrapping="Wrap" Text="You'll see your greeting here"/>
        </StackPanel>
    </Grid>
</Window>

MainWindow.xaml.cs

using System.Windows;

namespace TestWpfApplication
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            GreetingsTextBlock.Text = "Hi " + FirstNameTextBox.Text + " " + LastNameTextBox.Text;
        }
    }
}

Second project - with tests:

MainWindowUiMap.cs

using CUITe.Controls.WpfControls;
using CUITe.SearchConfigurations;

namespace CodedUITestProject1.UiMap
{
    public class MainWindowUiMap
    {
        private readonly WpfWindow _uiUnderTest;

        public MainWindowUiMap()
        {
            _uiUnderTest = new WpfWindow(By.Name("TestWpfApplication"));
        }

        public string FirstNameTextBox
        {
            get { return _uiUnderTest.Find<WpfEdit>(By.Name("FirstNameTextBox")).Text; }
            set { _uiUnderTest.Find<WpfEdit>(By.Name("FirstNameTextBox")).Text = value; }
        }

        public string LastNameTextBox
        {
            get { return _uiUnderTest.Find<WpfEdit>(By.Name("LastNameTextBox")).Text; }
            set { _uiUnderTest.Find<WpfEdit>(By.Name("LastNameTextBox")).Text = value; }
        }

        public string GreetingsTextBlock
        {
            get { return _uiUnderTest.Find<WpfText>(By.Name("GreetingsTextBlock")).DisplayText; }
        }

        public void ClickSayHeyButton()
        {
            _uiUnderTest.Find<WpfButton>(By.Name("GreetingsButton")).Click();
        }
    }
}

TestMainWindowGreetings.cs

using System.Threading;
using CodedUITestProject1.UiMap;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CodedUITestProject1.Tests
{
    [CodedUITest]
    public class TestMainWindowGreetings
    {
        [TestMethod]
        public void TestGreetings()
        {
            ApplicationUnderTest.Launch(@"D:\Roxton\Documents\Visual Studio 2013\Projects\TestWpfApplication\TestWpfApplication\bin\Debug\TestWpfApplication.exe");
            var uiUnderTest = new MainWindowUiMap();
            Thread.Sleep(1000);
            uiUnderTest.FirstNameTextBox = "John";
            uiUnderTest.LastNameTextBox = "Doe";
            uiUnderTest.ClickSayHeyButton();
            var greetingsTextBlockValue = uiUnderTest.GreetingsTextBlock;
            Assert.AreEqual("Hi John Doe", greetingsTextBlockValue);
        }
    }
}

During the execution of the test in the TestMainWindowGreetings class, I'm getting the following exception:

Test Name: TestGreetings
Test FullName: CodedUITestProject1.Tests.TestMainWindowGreetings.TestGreetings
Test Source: d:\Roxton\Documents\Visual Studio 2013\Projects\TestWpfApplication\CodedUITestProject1\Tests\TestMainWindowGreetings.cs : line 13
Test Outcome: Failed
Test Duration: 0:00:07,5583427

Result Message:
Test method CodedUITestProject1.Tests.TestMainWindowGreetings.TestGreetings threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'UIA'
FrameworkId: 'Wpf'
ControlType: 'Edit'
Name: 'FirstNameTextBox'
Search may have failed at 'TabGroup|ST:0:0:{34e76e81-ee4a-11d0-ae2e-00a0c90ff...' TabList as it may have virtualized children. If the control being searched is descendant of 'TabGroup|ST:0:0:{34e76e81-ee4a-11d0-ae2e-00a0c90ff...' TabList then including it as the parent container may solve the problem. ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
Result StackTrace:
at Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IScreenElement.FindAllDescendants(String bstrQueryId, Object& pvarResKeys, Int32 cResKeys, Int32 nMaxDepth)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindAllScreenElement(String queryId, Int32 depth, Boolean singleQueryId, Boolean throwException, Boolean resetSkipStep)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindScreenElement(String queryId, Int32 depth, Boolean resetSkipStep)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Int32 maxDepth, Int32& timeLeft)
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapControlNotFoundException(COMException ex, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowComException(COMException innerException, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, String queryId)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Int32 maxDepth, Int32& timeLeft)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetElement(Boolean useCache, ISearchArgument searchArg)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.Search(ISearchArgument searchArg)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindInternal()
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindControlIfNecessary()
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetPropertyPrivate(String propertyName, Object value)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.<>c__DisplayClass3e.b__3d()
at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetProperty(String propertyName, Object value)
at Microsoft.VisualStudio.TestTools.UITesting.WpfControls.WpfEdit.set_Text(String value)
at CUITe.Controls.WpfControls.WpfEdit.set_Text(String value)
at CodedUITestProject1.UiMap.MainWindowUiMap.set_FirstNameTextBox(String value) in d:\Roxton\Documents\Visual Studio 2013\Projects\TestWpfApplication\CodedUITestProject1\UiMap\MainWindowUiMap.cs:line 18
at CodedUITestProject1.Tests.TestMainWindowGreetings.TestGreetings() in d:\Roxton\Documents\Visual Studio 2013\Projects\TestWpfApplication\CodedUITestProject1\Tests\TestMainWindowGreetings.cs:line 17

Looks like MainWindow can be found but I can't find a single control in it.
Solution files are attached.
TestWpfApplication.zip

Navigation with the page pattern

I have been hunting around for a CUTEe sample, but not much luck on the net, codeplex, samples or git issues.

I would like to use the page object to inplement the page pattern, but I am unsure where navigation belongs. I have seen two examples where the author has write a custom method in a page object that does a "NavigateTo" and returns another page object. This introduces a coupling between two pages, which (may or may not) be a good idea when an web app requires maintenance on hundreds of pages.

What other ways can pages be used and have the page navigation isolated from the page object?

thanks.

AppVeyor badge

I think we should add a AppVeyor badge to README.md, indicating to readers that the project is exorcised by a CI server. As an example, see the badge on Entity Framework on GitHub.

The Markdown format of the badge can be found under AppVeyor project settings, but I don't have access to it.

Add support to find a WinControl by index

I would like to be able to find a WinControl by index.

In some cases, Win32 controls on a dialog that are created do not have a consistent unique identifier.

For example, in an MSI: https://sourceforge.net/p/wix/feature-requests/535/

When trying to replace the use of TestStack.White with CUIte, this is a missing piece, as TestStack.White supports this kind of search criteria:
https://github.com/TestStack/White/blob/master/src/TestStack.White/UIItems/Finders/SearchCriteria.cs#L63

For example,
WinText labelControl = myDialog.Find<WinText>(By.Index(1));

Create NuGet package

In addition to distribute CUITe using a installer, there should be an option to install CUITe using NuGet.

Error trying to execute test using CUITe framework

Hello,
I am hoping to incorporate the CUITe framework for our automated testing. I have used nuget to add the framework dll to Visual Studio 2015. However, when I attempt to run a test I receive the following:

Test Name: CodedUITestMethod1
Test FullName: CUITe.CodedUITest2.CodedUITestMethod1
Test Source: C:\Users\m3ac-piniond\Source\CUITe\CUITe\CodedUITest2.cs : line 31
Test Outcome: Failed
Test Duration: 0:00:01.054266

Result StackTrace: at CUITe.CodedUITest2.CodedUITestMethod1()
Result Message:
Test method CUITe.CodedUITest2.CodedUITestMethod1 threw exception:
System.IO.FileLoadException: Could not load file or assembly 'CUITe, Version=2.0.81.0, Culture=neutral, PublicKeyToken=a67a8fd362ae8334' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I have tried removing and adding the package back, but the error persists. Also, here are my

packages.config:

<-packages>
<-package id="CUITe.VS2013" version="2.0.81-beta" targetFramework="net46" />
</-packages>

and app.config:

<-configuration>
<-runtime>
<-assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
</-assemblyBinding>
</-runtime>
</-configuration>

I am hopeful someone can help me as I am currently stuck but would really like to implement CUITe as part of this project. Thanks

Getting "SetProperty of "Text" is not supported on control type: Window" when trying to set text in textBox

Getting "SetProperty of "Text" is not supported on control type: Window" when trying to set text in textbox.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CUITe.SearchConfigurations;
using Microsoft.VisualStudio.TestTools.UITesting;
using CUITe.Controls.HtmlControls;

namespace ABCSmokeTestCuite.ObjectRepository
{
    public class ABCLoginPage : BrowserWindowUnderTest
    {
        public ABCLoginPage()
            : base("ABC - Log-in Page")
        {
        }

        public ABCLoginPage(string windowTitle)
            : base(windowTitle)
        {

        }

        public HtmlEdit txtTemp1 = new HtmlEdit(By.SearchProperties("Id=ctl00_ContentPlaceHolder1_loginABC_UserName"));        
        public HtmlPassword txtTemp2 = new HtmlPassword(By.SearchProperties("Id=ctl00_ContentPlaceHolder1_loginABC_Password"));
        public HtmlInputButton btnLogIn = new HtmlInputButton(By.SearchProperties("Id=ctl00_ContentPlaceHolder1_loginABC_LoginButton"));
    }
}


public void Login(string url, string username, string password)
{

       MBESLoginPage loginPage = BrowserWindowUnderTest.GetBrowserWindow<ABCLoginPage>("ABC - Log-in Page");

       loginPage.txtTemp1.Text = username;
       loginPage.txtTemp2.Text = password;
       loginPage.btnLogIn.Click();
}

ReSharper

Are you using ReSharper? I would like to commit a ReSharper settings file, and fix the issues ReSharper is complaining about.

Standalone WpfControl

Would be very useful to have a standalone (non-abstract) WpfControl class in situations when you need to wait for the control to appear or disappear and it doesn't really matter what type of the control should be there.

Installing the "CUITe for Visual Studio 2010" NuGet package doesn't set binding redirects in app.config correctly

Installing the "CUITe for Visual Studio 2010" NuGet package doesn't set binding redirects in app.config correctly.

Here are the contents of app.config after installing the NuGet package (v2.0.253-beta) in a clean Visual Studio 2010 Test project:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.TestTools.UITest.Extension" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="10.0.0.0-14.0.0.0" newVersion=".0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.TestTools.UITesting" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="10.0.0.0-14.0.0.0" newVersion=".0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Notice that newVersion=".0.0" should actually be newVersion="10.0.0.0".

This is a result of using {env:VisualStudioVersion} in install.ps1 in the NuGet package.

Improvements to WinForms Search

CUITe is lacking in support for WinForms as mentioned in PR #20

In CodedUI the unique identifying property for WinForms is 'ControlName'.

Most inspection tools such as UIA Verify will see this value as AutomationId but CodedUI gives it a different name in this case.

I would like to add a ControlName configurator and modify the By object so that users can take advantage of this search property.

Add support for `Find<T>()` where T doesn't require a constructor that takes a `By` search configuration parameter

In v1.0.6 of CUITe, I am able to do the following:

            ApplicationUnderTest applicationUnderTest = ApplicationUnderTest.Launch(exeFilePath);

            StartTrialWindow startTrialWindow = new StartTrialWindow(applicationUnderTest.Process.MainWindowHandle);

            startTrialWindow.StartButton.Click();
    public class StartTrialWindow : CUITe_WinWindow
    {
        public StartTrialWindow(IntPtr windowHandle) : base("Name=Start Trial")
        {
            UITestControl mainWindow = UITestControlFactory.FromWindowHandle(windowHandle);

            this.Wrap(mainWindow);
        }

       public CUITe_WinButton StartButton { get { return Get<CUITe_WinButton>("Name~Start"); } }
    }

However when migrating to CUITe v2.0.265, I expected to do the following:

ApplicationUnderTest applicationUnderTest = ApplicationUnderTest.Launch(exeFilePath);

StartTrialWindow startTrialWindow = applicationUnderTest.Find<StartTrialWindow>();

startTrialWindow.StartButton.Click();
    public class StartTrialWindow : WinWindow
    {
        public StartTrialWindow() : base(By.Name("Start Trial"))
        {
        }

       public WinButton StartButton { get { return Find<WinButton>(By.NameContains("Start")); } }
    }

But instead, I get the following run-time exception:

System.ArgumentException: No constructor for type 'StartTrialWindow' contains arguments in the following order:
  1. By - Search configuration
at CUITe.Controls.ControlBaseFactory.Create(Type controlType, By searchConfiguration)
   at CUITe.Controls.ControlBaseFactory.Create[T](By searchConfiguration)
   at Microsoft.VisualStudio.TestTools.UITesting.UITestControlExtensions.Find[T](UITestControl self, By searchConfiguration)
   at ...

Application response issues through cuite framework.

Hi All,
I recently faced an issue while working on CUITe framework.
There is a continuous progress(or loading) seen while my framework clicks on any button in the application, sometimes even it resulted in Timeout, Although when we try to click the same button manually it gets loaded quite quickly and the application response is proper.
Can anyone help me in this regard, or someone did face this ever??
Thanks,
Sonal

'By' syntax used in Selenium

What are your thought regarding the By syntax used in Selenium. Examples can be found here.

The syntax of searchProperties in CUITe is pretty advanced in my opinion. When first introduced with the syntax I was confused with what to write there. Developers new to CUITe might find it easier to start using CUITe if there existed a By class that help with defining search properties.

Of course there should also be a method on the By class that lets developers write search properties in the compressed syntax currently supported.

CUITe.Silverlight.dll for VS2013 and net40 doesn't contain any controls

CUITe.Silverlight.dll for VS2013 and net40 doesn't contain any controls

When building, the following warning appears:

C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3274: The primary reference "Microsoft.VisualStudio.TestTools.UITest.Extension.Silverlight, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it was built against the ".NETFramework,Version=v4.5" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0". [C:\Working\github\icnocop\cuite\master\src\CUITe.Silverlight\CUITe.Silverlight.csproj]

Instead, the "Microsoft.VisualStudio.TestTools.UITest.Extension.Silverlight.dll" from either the Visual Studio v10 or v11 should be referenced, which targets .net 4.0.

The "Microsoft.VisualStudio.TestTools.UITest.Extension.Silverlight.dll" from Visual Studio 2013 (v12) only targets .net 4.5.

Document how to configure ReSharper to use CUITe.sln.DotSettings correctly

Document how to configure ReSharper to use CUITe.sln.DotSettings correctly.

Which version of ReSharper is required?

In Visual Studio 2013, I go to Resharper > Manage Options... > Solution 'CUITe' team-shared > Add Layer > Open Settings File... > Open "CUITe.sln.DotSettings" > Close.
But then if I try to find code issues in a file which has a using statement within the namespace, Resharper doesn't find any issues.
Do you have any other options in Resharper's Setting Layers for the solution?

Unexpected control being found when calling `Find<WinButton>(By.ControlName("..."))`

An unexpected control is being found when calling Find<WinButton>(By.ControlName("...")).

The behavior can be noticed in an existing unit/integration test.

File: .\src\SystemsUnderTest\Sut.WinForms.ScreenObjectsTest\ScreenObjectsTest.cs

        [TestMethod]
        public void NavigateToModalDialog()
        {
            // Act
            var dialogScreen = mainScreen.MiddleScreenObject.NavigateToModalDialogScreen();

            // Assert
            Assert.IsTrue(dialogScreen.CloseButtonExists);
        }

If I manually run this test, I notice that the Minimize button in the title bar gets clicked instead of the button with the control name buttonOpenModalDialog.

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.