Pages

Friday, 29 April 2016

Test Project Structure in Coded UI

Coded UI Porject

 >> functionality1.cs
            >> TestCaseID_TestMethod1
            >> TestCaseID_TestMethod2
            >> TestCaseID_TestMethod3
            .....
            >> TestCaseID_TestMethodn

 >> functionality2.cs
            >> TestCaseID_TestMethod1
            >> TestCaseID_TestMethod2
            >> TestCaseID_TestMethod3
            .....
            >> TestCaseID_TestMethodn

 >> functionality3.cs
            >> TestCaseID_TestMethod1
            >> TestCaseID_TestMethod2
            >> TestCaseID_TestMethod3
            .....
            >> TestCaseID_TestMethodn
...

 >> functionalityn.cs
            >> TestCaseID_TestMethod1
            >> TestCaseID_TestMethod2
            >> TestCaseID_TestMethod3
    .....
            >> TestCaseID_TestMethodn

For Free Demo Call me on Mobile/Email - 9597100592/vardhancuit@gmail.com
You can help yourself with more information from my website www.software-testing-zone.info

Synchronization in Coded UI

About Synchronization:
Making sure that the speed of automation scripts execution should be in sync with application under test (AUT) response/speed
To enable synch,  Coded UI/QTP/.. Uses WAIT statement or Test Settings

Different levels of Sync:
Test level sync
          Default wait time is 60000 milliseconds
Statement level sync
          Unconditional wait – Playback.Wait
          Conditional wait – all other wait statements

Purpose of Wait statements:
A Wait statement can be used for:
          a web page to load
          a button to become enabled or disabled
          a client server communications to finish

Wait statements
The following wait statements  could be used to wait or suspend the execution until the specified time period is elapsed:

    Playback.wait()

      -  Waits for specific time period

      -  Default time could be  changed by using ‘WaitForReadyTimeout’ in Playback settings

Wait statements  on controls:
WaitForControlReady() – Waits for the control to be ready to accept keyboard or mouse input.

WaitForControlEnabled() – Waits for control to be enabled

WaitForControlExist() – Waits for control to exist on UI

          Example: Expecting a dialogbox after application has done validation of parameters

WaitForControlNotExist() – Waits till the control cease to exist on application

          Example: progress bar to go away

WaitForControlPropertyEqual (string propertyName, object propertyValue)

          Example: status text to change to Done

WaitForControlPropertyNotEqual (string propertyName, object propertyValue)

WaitForControlCondition – Could be used for a complex wait operation (OR operation) on a specific control

          Example: to wait until the status text is “Succeeded” or “Failed”
          Sample Code:
              // Define the method to evaluate the condition
                private static bool IsStatusDone(UITestControl control)
                {
                         WinText statusText = control as WinText;
                         return statusText.DisplayText == "Succeeded" || statusText.DisplayText  
                          == "Failed";
                 } 

              // In test method, wait till the method evaluates to true
               statusText.WaitForControlCondition(IsStatusDone);

WaitForCondition – Could be used for complex wait operation (OR operation) on multiple controls

          Example: to wait until the status text is “Succeeded” or error dialog is displayed
          Sample Code:
              // Define the method to evaluate the condition
    private static bool IsStatusDoneOrError(UITestControl[] controls)
    {
        WinText statusText = controls[0] as WinText;
        WinWindow errorDialog = controls[1] as WinWindow;
        return statusText.DisplayText == "Succeeded" ||             errorDialog.Exists;
    }

               // In test method, wait till the method evaluates to true
                   UITestControl.WaitForCondition<UITestControl[]>(new UITestControl[] { 
                    statusText, errorDialog }, IsStatusDoneOrError);

For Free Demo Call me on Mobile/Email - 9597100592/vardhancuit@gmail.com
You can help yourself with more information from my website www.software-testing-zone.info

Cross Browser Testing in Coded UI

Direct Cross Browser testing is not possible using Coded UI, It can be achieved using selenium components.
Please follow the simple 6 steps mentioned below manually then you can start writing cross-browser tests using Coded UI.

1. Download CodedUITestCrossBrowserTest.msi from the link https://visualstudiogallery.msdn.microsoft.com/11cfc881-f8c9-4f96-b303-a2780156628d
then install and verify that Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowserProxy.dll is found in the following location:

"%ProgramFiles%\Common Files\microsoft shared\VSTT\Cross Browser
Selenium Components" (for 32 bit machines)

"%ProgramFiles(x86)%\Common Files\microsoft shared\VSTT\Cross Browser
Selenium Components" (for 64 bit machines)

2. Download chrome driver and selenium dot net bindings zip files from below link https://visualstudiogallery.msdn.microsoft.com/11cfc881-f8c9-4f96-b303-a2780156628d

3. Right click on the downloaded zip files.

4. Select "properties".

5. Under "General" tab, click on the "Unblock" button.

6. Now unzip both the files and copy the contents to the following path (for the selenium-dotnet 2.43.1 binaries, copy the contents of net40 folder):

"%ProgramFiles%\Common Files\microsoft shared\VSTT\Cross Browser Selenium Components" (for 32 bit machines)

"%ProgramFiles(x86)%\Common Files\microsoft shared\VSTT\Cross Browser Selenium Components" (for 64 bit machines)

On continuation,
BrowserWindow.CurrentBrowser = "chrome";
                             Or
BrowserWindow.CurrentBrowser = "firefox"; can be used.

For Free Demo Call me on Mobile/Email - 9597100592/vardhancuit@gmail.com
You can help yourself with more information from my website www.software-testing-zone.info