Friday, May 15, 2020

WinAppDriver Tutorial: Using Appium Client For Object Inspection in Windows Desktop Test Automation

Appium Server Windows with Free Test Automation Tool WinAppDriver Object Inspector


Download free e-book Windows Test Automation With Appium Windows Application Driver in C# .Net


Introduction to Appium Desktop Client


When I created my Udemy Course about WinAppDriverUI Automation Testing in 2019, I relied solely on the WinAppDriver UI Recorder to inspect various Windows application elements. I showed how to automate. Only a little information was available on the subject back then. I recently came across another tool we can use to look into various application elements and find their attributes for UI test automation.

This article shows you just that because it has the potential to make your life easier. I've also added the same videos to my Udemy course and YouTube channel. This tool is called the Appium Desktop.  

This post will serve as an introductory WinAppDriver tutorial. I am going to show you how to use an alternative of
WinAppDriver UI Recorder.
You can download it from the Appium.io website. 

Before we proceed, please remember there are two prerequisites for using Appium Desktop. 
  1. Enable Windows 10 Developer Mode on your PC
  2. You need to have WinAppDriver 1.1 or above installed on your PC. 



    You don't need to install Node.js to run an Appium desktop client, as shown in this WinAppDriver tutorial. Let me google the search term Appium Desktop client quickly and guide you. You also don't need to download WinAppDriver UI Recorder.

    Download Appium Desktop on Windows

    This will take us to the GitHub repository of the Appium Desktop project. You will need to download the Appium-windows.exe from here and use it to install an Appium desktop.

    Please see the screenshot below.


    Appium Desktop Download Items
    Once you've got Appium Desktop installed, you can proceed further. We are going to start using Appium Desktop for inspecting Windows Applications. If you have the proper tools installed, please note that you can use the same utility to check apps on other Appium-supported platforms, such as Android and iOS. Although that's beyond the scope of this blog.



    Running Appium Desktop Client and Connecting to a Windows Application


    Before we use the Appium Desktop Client to inspect the elements of a Windows application's features, we must start the Windows Application Driver through WinAppDriver.exe


    Learn WinAppDriver Automation Testing Free Tools

    Now let's run the Appium Desktop Client; you can find it in your Windows applications. First, click the "Start" button and type Appium. 



    Appium Client in Windows Apps List

    Now click the "Appium" icon to open the application. The Appium desktop client can take a few seconds to load. Then, on the main Appium UI, go to the "File" menu and select "New Session Window." 

    Appium New Session on Windows

    A new dialog box will open up. The tab "Custom Server" will be selected. I'll leave the remote host and remote port fields unchanged. In the Remote Path field, I'm going to put a forward slash. Then there's this table-like Ui to specify Desired Capabilities. I will click on the first text box containing the "Name." I will type the word app in there. Please note the phrase app will be small. In the value textbox, I'll paste the user mode ID of the Microsoft Windows 10 Calculator app, which is:

    Microsoft.WindowsCalculator_8wekyb3d8bbwe!App


    I've shown how to find this value in my course. The final screenshot of the Appium custom server is shown below. FYI: 

    Setting AppiumOptions in Appium Client for Windows Automation Example



    Now Appium Client will connect the instance of WinAppDriver, which is running on this PC and listening on port number 4723. Remember, we started it earlier. I'll press the button "Start Session."

    Appium Client Inspecting Windows Calculator Example


    The calculator app will start, and you'll get a preview inside the Appium UI Recorder. You can hover the mouse on various application controls under the test, highlighted in yellow. In my case, the mouse cursor is also changing into a hand, but it was not captured in the screenshot.


    Appium UI inspector

    Let's end this section here, and we will learn more about the free Appium UI Inspector
    in the selection below. It is an essential tool for Appium-based automation.


    Inspecting Elements Using Appium Desktop Client and WinAppDriver For Automated Testing


    Once we have created a session in Appium Client, we can inspect various elements of the loaded application. The Appium Client object inspector UI is pretty simple. A button row is on the top, and "Select Elements" is clicked by default. 


    Appium Client Select Element Windows Automation
    1. We have the application preview loaded on the left side.
    2. "App Source" in the middle shows the hierarchy of application controls. 
    3. The rightmost panel is "Selected Element." It will populate when we click an element. 


    Appium Client Object Inspector Windows Selected Element




    For Example, we will hover the mouse on the application preview shown in the Appium Desktop Client. 


    You will see that the element under the cursor will highlight yellow. Let's click on button two in the application preview. You see, its color will change. In addition, you'll find tributes to this Windows Element will load in the right-hand pane. I've highlighted some properties/attributes (Name, AutomationId) that we can use for automation in the screenshot below.


    Windows WebElement Properties in Appium Client GUI Inspector

    The same thing will happen if we click the calculation results textbox on the top. 

    You can use the Appium desktop client to inspect Windows applications. However, other options on this screen could be more helpful. Instead, click on the given line to find out How to Download and Run WinAppDriver UI Recorder.

    Oxygen IDE Support: 


    Please note that you can record automated UI tests using Appium Desktop Inspector to run with Oxygen IDE. You'll need to have proper tools installed for that. This includes Android Studio, which is overhead, but so far, that's the way Oxygen IDE architecture is, and they don't have any plans to remove the dependency anytime soon. You can find more by visiting this link.

    You can now play with the inspector further to see more options. I am going to close it now. In the following video, I'll show you how to use the app arguments desired capability in Appium Desktop Client.

    app arguments Specifying Additional Desired Capabilities in
    Appium Desktop Client


    How to use appArguments AppiumOption/DesiredCapability in Appium? 

    We can specify more additional capabilities using the Appium Desktop Client. These capabilities can have various effects on our tests and are something not available in WinAppDriver UI Recorder. For Example, if we want to open Notepad with a file loaded into it already. Please note that you can't do the same thing in WinAppDriver UI Recorder software.

    Let us create a new session. In the app's default capability, I'll put "Notepad." Then I'll click the plus sign and add app arguments in the desired skills. Finally, I'll put the file's path we want to open in the value field.

    For Example, in my case, C:\Users\Naeem\Desktop\bunch of text.txt. Please note that we won't put double quotes around the path. The final screenshot of our new Appium client custom server to launch Windows 10 Notepad with a file opened inside of it is given below:


    How to configure Appium desktop client with WinAppDriver on Windows

    I'll click the "Start Session" button. You'll see that the file you specified as a parameter will open. 



    If you're doing Microsoft Excel automation, Microsoft Excel can use the same technique to open a file right out of the gates. You may need to test an Excel plugin with test automation using WinAppDriver(Free automation tool).


    Click on the link to find out "How to Download and Run WinAppDriver UI Recorder."
    It is also possible to open files in Microsoft Excel launched through WinAppDriver using appArguments Appium Option. 
    Specify the desired capabilities in your test automation code will be done through the method call listed below: 

    AppiumOptions.AddAdditionalCapability("appArguments", "c:\textfile.txt");
    AppiumOptions.AddAdditionalCapability("ms:waitForAppLaunch", "50");

    ms:waitForAppLaunch Handling Splash Screen in WinAppDriver


    How to wait for an application splash screen to display? For Example, how to use ms:waitForAppLaunch AppiumOption? 

    Some applications show a splash screen when they launch. Unfortunately, the splash is mistakenly considered the main application window by the WinAppDriver, leading to automation failure. 



    Microsoft Outlook Automation Testing with Appium WinAppDriver



    If you're using WinAppDriver 1.2 RC, you can also make the WinAppDriver wait a bit so that the splash goes away, and then the WinAppDriver attaches to the application window. 

    For Example, let's try a demo with Microsoft Outlook(2019), a Desktop e-mail client application. 

    A free code sample of Outlook 2019 automation using WinAppDriver can be found in your GitHub repository. I am going to launch it straightforwardly. Then, I'll create a new session window and put Outlook against the "app" in desired capabilities. 

    Now I'll click the "Start Session" button.


    Appium Client Object Inspector Loading Outlook for WinAppDriver Automation


    You'll see that the app preview will not load. The progress animation will keep spinning. Let's close the session window and come again. This time, I'm going to add a new Desired Capability. In the name field, I'll put ms:waitForAppLaunch in the value field, I'll put the number 15. 

    Now I'll click the "Start Session" button. 


    Windows Outlook Appium Client AppiumOptions Values

    This time, you'll see that the application preview will take a while to load in the Appium Desktop Client. This is because now you can check all Windows elements' properties inside this application. 
    Outlook Windows Mailing List Screenshot for Free Windows Automation Tool



    This is the end of this article, and I hope you found it helpful. Please feel free to ask questions.

    Do share it in your social circles as well. Please also visit my Udemy course; the link is given AppiumWinAppDriver UI Automation Testing.

    Hopefully, you found this lesson to be valuable. If you want me to write another WinAppDriver tutorial, just let me know. This article was updated in 2023. 

    Sunday, May 3, 2020

    vstest.console.exe commandline options for test automation, help dump



    Microsoft (R) Test Execution Command Line Tool Version 16.4.0
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Usage: vstest.console.exe [Arguments] [Options] [[--] <RunSettings arguments>...]]

    Description: Runs tests from the specified files.

    Arguments:

    [TestFileNames]
          Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern
          by spaces. Set console logger verbosity to detailed to view matched test files.
          Examples: mytestproject.dll
                    mytestproject.dll myothertestproject.exe
                    testproject*.dll my*project.dll

    Options:

    --Tests|/Tests:<Test Names>
          Run tests with names that match the provided values. To provide multiple
          values, separate them by commas.
          Examples: /Tests:TestMethod1
                    /Tests:TestMethod1,testMethod2

    --TestCaseFilter|/TestCaseFilter:<Expression>
          Run tests that match the given expression.
          <Expression> is of the format <property>Operator<value>[|&<Expression>]
             where Operator is one of =, != or ~  (Operator ~ has 'contains'
             semantics and is applicable for string properties like DisplayName).
             Parenthesis () can be used to group sub-expressions.
          Examples: /TestCaseFilter:"Priority=1"
                    /TestCaseFilter:"(FullyQualifiedName~Nightly
                                      |Name=MyTestMethod)"

    --Framework|/Framework:<Framework Version>
          Target .Net Framework version to be used for test execution.
          Valid values are ".NETFramework,Version=v4.5.1", ".NETCoreApp,Version=v1.0" etc.
          Other supported values are Framework40, Framework45, FrameworkCore10 and FrameworkUap10.

    --Platform|/Platform:<Platform type>
          Target platform architecture to be used for test execution.
          Valid values are x86, x64 and ARM.

    --Settings|/Settings:<Settings File>
          Settings to use when running tests.

    RunSettings arguments:
          Arguments to pass runsettings configurations through commandline. Arguments may be specified as name-value pair of the form [name]=[value] after "-- ". Note the space after --.
          Use a space to separate multiple [name]=[value].
          More info on RunSettings arguments support: https://aka.ms/vstest-runsettings-arguments

    -lt|--ListTests|/lt|/ListTests:<File Name>
          Lists all discovered tests from the given test container.

    --Parallel|/Parallel
          Specifies that the tests be executed in parallel. By default up
          to all available cores on the machine may be used.
          The number of cores to use may be configured using a settings file.

    --TestAdapterPath|/TestAdapterPath
          This makes vstest.console.exe process use custom test adapters
          from a given path (if any) in the test run.
          Example  /TestAdapterPath:<pathToCustomAdapters>

    --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value]
          Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash.
          It creates an output file in the current directory as "Sequence.xml",
          that captures the order of execution of test before the crash.
          You may optionally choose to collect process dump for the test host.
          When you choose to collect dump, by default, a mini dump will be collected on a crash.
          You may also choose to override this default behaviour by some optional parameters:
          CollectAlways - To collect dump on exit even if there is no crash (true/false)
          DumpType - To specify dump type (mini/full).
          Example: /Blame
                   /Blame:CollectDump
                   /Blame:CollectDump;CollectAlways=true;DumpType=full

    --Diag|/Diag:<Path to log file>
          Enable logs for test platform.
          Logs are written to the provided file.

          Change the trace level for logs as shown below
          Example: /Diag:<Path to log file>;tracelevel=<Defaults to "verbose">
          Allowed values for tracelevel: off, error, warning, info and verbose.

    --logger|/logger:<Logger Uri/FriendlyName>
          Specify a logger for test results. For example, to log results into a
          Visual Studio Test Results File (TRX) use /logger:trx[;LogFileName=<Defaults to unique file name>]
          Creates file in TestResults directory with given LogFileName.

          Change the verbosity level in log messages for console logger as shown below
          Example: /logger:console;verbosity=<Defaults to "normal">
          Allowed values for verbosity: quiet, minimal, normal and detailed.

          Change the diagnostic level prefix for console logger as shown below
          Example: /logger:console;prefix=<Defaults to "false">
          More info on Console Logger here : https://aka.ms/console-logger

    --ResultsDirectory|/ResultsDirectory
          Test results directory will be created in specified path if not exists.
          Example  /ResultsDirectory:<pathToResultsDirectory>

    --ParentProcessId|/ParentProcessId:<ParentProcessId>
          Process Id of the Parent Process responsible for launching current process.

    --Port|/Port:<Port>
          The Port for socket connection and receiving the event messages.

    -?|--Help|/?|/Help
          Display this usage message.

    --Collect|/Collect:<DataCollector FriendlyName>
          Enables data collector for the test run. More info here : https://aka.ms/vstest-collect

    --InIsolation|/InIsolation
          Runs the tests in an isolated process. This makes vstest.console.exe
          process less likely to be stopped on an error in the tests, but tests
          may run slower.

    @<file>
          Read response file for more options.

      To run tests:
        >vstest.console.exe tests.dll
      To run tests with additional settings such as  data collectors:
        >vstest.console.exe  tests.dll /Settings:Local.RunSettings


    Saturday, May 2, 2020

    How to generate test run reports for C#, CodedUI, Appium, Selenium test automation

    C# .Net Windows Applications Test Explorer Window Visual Studio Coded UI Appium WinAppDriver Selenium Automated Testing
    Sharing a screenshot of a passed test works, in some cases.
    If you've worked on test automation in C# and Visual Studio, you might be perplexed about why no reports are generated after the test run?
    Maybe there was something you could send to your manager as an e-mail attachment so that s/he could sleep in peace.
    Sending a screenshot of Visual Studio with Test Explorer showing it's all green after a test execution works in some cases.
    Before you proceed further, please note that all of this information and much more about test automation with WinAppDriver can be learned through my course. You can sign up now with a discount by clicking the link below:
    Learn automated UI testing using WinAppDriver and C#



    But some managers are suspicious that maybe you came up with these results using with debugging tools. Maybe you'd been jumping around code with Ctrl + Shift + F10.
    Even if you don't have a manager doubting your work, it is still a good idea to be able to run your automated testing scripts without the Visual Studio or outside the Visual Studio, without the Test Explorer window.
    Generate automated test run reports:
    Yet another advantage of such stand alone test automation execution is that you can produce a [automation] test run report. This report is generated in .trx format. I'm going to show you how to just that in this article.

    How to run test automation from command prompt?
    Please note that this is useful for both Appium WinAppDriver, Selenium, and Coded UI tests. In general, any test automation script, be it written using MsTest or Visual Studio Unit Testing Framework can be run using Visual Studio Developer Command Prompt.
    For this I'll click the Windows button and type Developer Command Prompt.
    VS Developer Command Prompt for running test automation and generate test report
    Windows: Developer Command Prompt Search

    This is how Visual Studio 2019 developer command prompt looks like.

    Visual Studio 2019 Developer Command Prompt Example Demo


    Once the command prompt is open, change the directory to the path where the dll files of your test automation project are placed. You will use the CD dos command for this purpose. For example:
    C:\Users\Naeem\source\repos\WinFormsUITesting\WinFormsUITesting\bin\Debug


    Once you're inside the directory, type the following command

    vstest.console.exe

    Give a space and then put the name of the test dll file. In my case, it is WinFormsUITesting.dll.
     put another space and then specify /logger:trx. Overall, the command will look as below:

    vstest.console.exe WinFromsUITesting.Dll /logger:trx

    After typing the command, hit the enter key. Notice that you don't need to place double quotes around the test assembly name.

    If you want to see list of all options exposed by vstest.console.exe, just type it without any parameters. A detailed help will be shown on console.

    The details of all information about vstest.console.exe can be seen here.

    vstest.console.exe help


    Once the automation is finished running, the path of the generated .trx file is shown on the command line as displayed in the screenshot below.



    A .trx file can be opened with any version of Visual Studio, be it community edition. It shows the results of a test run.


    If you have Visual Studio installed and you double click the .trx file, it will open in Visual Studio and show test results in rows of red and green tests. A screenshot of test results in Visual Studio 2019 is displayed below FYI:

    If you double click any row in the test results, more details related to that specific test method will be shown up top. A screenshot is given below FYI. 


    Just a reminder, all of this information and much more about test automation with WinAppDriver can be learned through my course. You can sign up now with a discount by clicking the link below:
    Learn automated UI testing using WinAppDriver and C#



    Friday, May 1, 2020

    What Is Automated UI Testing? How Can My WinAppDriver Online Course Teach You Automated Testing w/ Appium Easily?


    In the following article, you will get a thorough insight into why you should start learning UI testing from Udemy right now!

    There are few WinAppDriver tutorials available and almost no online courses. That is why I created a course about WinAppDriver. This course is in C#, but you can also use concepts shown with Java. I will split up the article into the following subheadings to make it easier for you to skim through:


    • Introduction
    • What is UI testing?
    • Where can I learn Automated UI testing?
    • Why take the Udemy course? Is It pocket friendly?
    • Features of “Appium WinAppDriver UI Automation Testing Windows Apps in C#”
    • Why taking this course during lockdown time is the best?
    • User Reviews of this Course 
    • Best ways to get exposure to automated UI Testing

    Introduction 

    UI or User Interface is the front end of your application that your users interact with on their screens. It is used in both Desktop and web applications.

    While User Interface (UI) Testing is a procedure used to test if the application is working accurately. UI testing can be performed physically by a human tester, or it tends to be performed automatically using a software program. Automatic UI testing is the atomization of manual test tasks.

    UI is a broad concept that can include both GUI and Command Line Interfaces (CLIs).



    What is UI Testing?

    Anything the user is going to do, might do, or can do, or regularly more significantly can do, however, you shouldn't have the option to do with your application while it is running, is a piece of the UI. 

    From each click of a button to entering data. You need to test what is expected to work and what is required to fail. 

    Here are a couple of model scenarios of areas to test what happens when the client: 

             Adds another column to a matrix and enters all the fields accurately. Does it save the information? 
             Clicks the Done button before all the fields are entered. Does it permit them to proceed? 
             Clicks cancel; when all the information is entered, does it dispose of the considerable amount of information? 
             Enters in an end date that is before a beginning date? 

    All of the logic your developer adds to make a point to ascertain values effectively, add data, change data, explore your application, and so on ought to be tested. So how would you do it? Automated UI Testing, indeed.




    Where Can I Learn Automated UI Testing?

    Quite a few platforms provide authentic courses for you to master this particular area of expertise. There is a need for desktop application test automation and web application test automation. 
    Below are some blogs, websites, and youtube channels that are a must-watch to learn automated testing.
    Based on my experience, I have listed all the essential blogs, websites, and Youtube channels that are a must-watch to learn automation testing.
             Free Training Tutorials -Guru 99 - Basics of Testing and Automation
             Naveen AutomationLabs

    Of all these worthy places to head to, my favorite is Udemy! And why is that so? I will explain that in the following section.
    But it is hard to come by a good WinAppDriver tutorial because only a few people chose to write about it.

    Why Take Udemy Course For Windows Desktop Automated UI Testing? Is It Cheap?


    Since people do adore things that are offered at low cost with excellent quality. Udemy is centered mainly around students, and as clearly, Students, by and large, can't manage the cost of Costly course material in this manner; most of the Udemy courses are pretty priced. 
    Udemy even offers free courses that are close to the paid courses.

    The content quality is the thing that makes it one of the most famous Online Learning platforms. 

    One more thing with Udemy Course producers is they turn out Coupons, which decrease the cost for their specific course. Some even pay 100% off coupons for their top-notch courses worth several dollars. 

    This causes them to get more users to reach and connect with, which also advantages the students.


    Automated Testing with WinAppDriver in C#



    The course contains 59 lectures. For now, you will be able to learn the following:
    • Automated Testing & UI Automation with Appium, WinAppDriver in C# .Net on Windows 10.
    • Desktop automation for RPA and functional testing of Windows/WinForms applications with Appium WinAppDriver in C# .Net, Visual Studio.
    • Windows Automation in Appium and WinAppDriver.
    Based on student feedback, the author keeps adding more videos and source code samples to the course.
    Two new sections have been added already.

    The course content is enlisted below:
    • Introduction to UI Automation of Windows Applications with Appium WinAppDriver.
    • Finding and Manipulating UI Elements with [Appium] WinAppDriver for Automation.
    • Using Automation Framework Visual Studio Unit Test Framework(MS Test).
    • Fusion: Combining [Appium] WinAppDriver plus MS Test Framework.
    • Data-Driven Testing with Ms. Test and Microsoft Excel.
    • WinForms Automated Testing with Appium WinAppDriver.
    • Appium WinAppDriver Test Automation General Scenarios.
    • Running Automated Tests Without Visual Studio, Generating Reports, and Test Filters from the command line (or Azure DevOps Pipelines). 

    Why Learning Automation in Lockdown is The Best Decision?

    Utilizing time in this period of worldwide lockdown in putting resources into self-awareness and learning pertinent new aptitudes can assist individuals with keeping up their certainty and inspiration, says Namrata Murlidhar, showcasing chief at LinkedIn Learning. 

    While influenced individuals will along these lines have all the more available time on their hands, activities are likewise restricted to the bounds of your home because of broad lockdown measures during the pandemic. 

    Jo Cresswell, professions master at occupations site Glassdoor, said that the expanding number of laborers being furloughed "sparkles a focus on the significance of transferable abilities." 
    “Keeping yourself stimulated and finding new ways to learn essential skills can make the eventual return to work smoother or open doors to new opportunities in the future, ” said Murlidhar, urging furloughed individuals to also stick to a routine as much as possible.


    User Reviews For “Appium WinAppDriver UI Automation Testing Windows Apps in C#”

    People who took advantage of learning this course from Udemy left 5-star rated reviews to thank the creator of this course.

    If someone is looking for Appium C# desktop application automation with Appium WinAppDriver, this is the only course on Udemy to kick start with.
    A screenshot of user reviews is given below. 
    Appium WinAppDriver Udemy Course Reviews
    Appium WinAppDriver Automated Testing Course Review

    Appium WinAppDriver UI Test Automation in C# Course Reviews
    Appium WinAppDriver Automated Testing Course review

    I hope this article has motivated you enough to learn from this worthy course.

    And if there is still some possibility of a no, then head over to Udemy official site for this course and watch for your own. How important this course is to be learned at this hour of worldwide lockdown/QUARANTINE.

    Chaio! J