Wednesday, February 27, 2019

Nunit Attributes

NUnit Attributes
 
  • [TestFixture]
    • Marks a class that contains tests

  • [Test]
    • Marks a method in a test class. The method becomes a test case.

  • [SetUp]
    • Marks a method which is executed just before each test method.
    • At most one such method per test class


  • [TearDown]
    • Marks a method which is executed after each test method.
    • At most one such method
    • Is not executed if a test fails, of if it throws an exception



  • [TestFixtureSetUp]
    • Marks a method which is executed once before execution of any test method.
    • At most one such method
    • Executed once, before the execution of the first test method in this fixture



  • [TestFixtureTearDown]
    • Marks a method which is executed once after all tests are completed.
    • Executed once, after the execution of the last test method in this fixture
    • At most one such method



  • [ExpectedException(ExceptionType)]
    • Marks a test which is expected to lead to a given Exceptiontype

  • [Category("name")]
    • Categorizes a given test fixture or test
    • Individual categories can be included or excluded in a test-run


  • [Ignore]
    • Marks a test method or a test class which (temporarily) should not be executed

Tuesday, February 26, 2019

How set up selenium grid with port step by step process

Selenium grid setup is process, we will divide this into 3 tasks, these are


1) Setup Hub
2) Setup  Nodes
3) Develop the scripts and execute.

1) Setup Hub

Download the latest Selenium Server file from http://docs.seleniumhq.org/download/
Selenium Grid – How to Easily Setup a Hub and Node

You can place the Selenium Server jar file anywhere in your hard drive, but now am placing into c drive.


2)  Go to cmd prompt 

3) Navigate where we placed selenium server . 

4) Enter ur selenium server as below. (version may be change )

java -jar selenium-server-standalone-2.53.0.jar -role hub  -port 6000


by default it will take port number as 4444 if you want you can change 

Selenium Grid_7

To verify whether hub is running, open the browser and navigate to http://localhost:6000/grid/console


Selenium Grid_7


2) Setup  Nodes 

1)  Go to cmd prompt .

2) Enter 

java -jar selenium-server-standalone-2.53.0.jar -role node -hub http://localhost:6000/grid/register -maxSession 5 



Selenium Grid_7

Go to the browser and verify 


Selenium Grid_7

Coded UI Keyboard.SendKeys("{Enter}")

Keyboard.SendKeys("{Enter}");

Browserwindow setup


--------- common method page ................................................


using Microsoft.VisualStudio.TestTools.UITest.Extension;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace Dell.SVL.NexusCore
{
  public static class Browserwindow
    {
        public static BrowserWindow browserWindow;
        public static void LaunchApplication(string appUrl, string bType = "IExplorer", bool clearData = true )
        {
            try
            {
                               
                browserWindow = BrowserWindow.Launch();
                if (clearData)
                {
                    BrowserWindow.ClearCache();
                    BrowserWindow.ClearCookies();
                } 
                browserWindow.NavigateToUrl(new Uri(appUrl));
                browserWindow.Maximized = true;
              

            }
            catch (Exception Ex)
            {
                //Console.WriteLine("Browser doesn't launched successfully");
                Assert.Fail(Ex.Message);
            }

        }

        public static void InitializePlayBackSettings()
        {
            try
            {
                if (!Playback.IsInitialized)
                {
                    Playback.Initialize();
                }

                Playback.PlaybackSettings.SmartMatchOptions = SmartMatchOptions.None;
                Playback.PlaybackSettings.AlwaysSearchControls = true;
                Playback.PlaybackSettings.MatchExactHierarchy = true;
                Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.UIThreadOnly;
                Playback.PlaybackSettings.MaximumRetryCount = 4;
                Playback.PlaybackSettings.SearchTimeout = 30000;

            }
            catch(Exception Ex)
            {
                Assert.Fail(Ex.Message);
            }
        }


        public static void ResetPlayBackSettings()
        {
            try
            {
                if (Playback.IsInitialized)
                {
                    Playback.StopSession();
                    Playback.Cleanup();
                }
            }
            catch (Exception Ex)
            {
                Assert.Fail(Ex.Message);
            }
        }

      public static void BrowserRefresh()
        {
            try
            {
                browserWindow.Refresh();
            }
          catch(Exception Ex)
            {
                Assert.Fail(Ex.Message);
            }
        }
    }
}

--------- test method page ................................................


  [TestInitialize]
        public void BeforeAll()
        {
            try
            {


                appUrl = testContextInstance.Properties["NexusUrl"].ToString();
                GenericMethods.KillProcessByName();
                Browserwindow.InitializePlayBackSettings();
                actions = new Actions();
                Browserwindow.LaunchApplication(appUrl);

            }
            catch (Exception Ex)
            {
                Assert.Fail(Ex.Message);
            }
        }




TestCleanUp


        [TestCleanup]
        public void AfterAll()
        {
            try
            {
                Browserwindow.ResetPlayBackSettings();
                actions = null;
                GenericMethods.KillProcessByName();
                GenericMethods.FreeUpMemory();

            }
            catch (Exception Ex)
            {
                Assert.Fail(Ex.Message);
            }
        }

Thursday, February 21, 2019

How to integrate a manual test case with automation test case


Step by step approach to How to integrate a manual test case with automation test case 



1) Go to MTM

2) Crate a manual test case with proper steps

3) Save test case.

4) Test case id will be generate like (567890)

5) Copy the test case id.

6) Go to Visual studio

7) Tools ... Options .... Work Items ....General ..... Visual studio compatibility mode select from drop down list.

8) Click on Ok button.

9) Find Team Explore tab with solution explore.

10) search with work item (test case number 567890).

11) it will open work item .

12) You can find Associated Automation ----- Select Automation test case name and save it.