Monday, May 30, 2016

Trouble shooting error messages on selenium c# -01

The CLR has been unable to transition from COM context 0x12aa9d0 to COM context 0x12aab40 for 60 seconds.

Above message is bit weird error message.


This happens to me in  middle of  debugging a selenium code via visual studio 2012.

Solution :
Debug -> Exceptions -> Managed Debug Assistants menu in Visual Studio and uncheck the ContextSwitchDeadlock

reff :http://stackoverflow.com/questions/2747916/the-clr-has-been-unable-to-transition-from-com-context-for-60-seconds


Thursday, May 26, 2016

Automatically run CodedUI test methods by scheduled tasak

1).Create the test methods and run it thru the test explorer at the visual studio.
You should get the green color test pass view at the test explorer.


2).Navigate to solution explorer and click on "Open folder on file explorer"

3.Inside the bin\debug find the .dll file.
There will we only one dll file.

4).Open a note pad and write down below things.

//Navigate to the debug folder where you found at the step 3.
cd "E:\Users\cja\documents\visual studio 2012\Projects\PowerBI\PowerBI\bin\Debug"

//some times windows will fail to navigate to the exact location so have to do this.Mos of the time this happens when the cd command contain some other drive rather than "C" drive.
e:

//Find the MSTest.exe path and add it to a variable.
Most of the time below is the default location of the MSTest.exe .
set mstestPath="C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE"

//we use the above variable and then the MSTest.exe file and then a keyword.
Keyword should be pointing tot the dll whcih we found at step 3.
%mstestpath%\mstest /testcontainer:PowerBI.dll

5).Save the file as a bat file
6).Make a scheduled task using the above bat file. :)



Tuesday, May 10, 2016

Important things on Appium - 2

I got a time out error as on the below.
I have highlighted the most important area of the error message.

Test Name: Validate_Availability_Of_Valid_Completion_By_Date_And_Time_At_Workorder_Details
Test FullName: AppiumDTZ.Test.Test_WorkOrderDetails.Validate_Availability_Of_Valid_Completion_By_Date_And_Time_At_Workorder_Details
Test Source: e:\QA automation\appium\AppiumTFS\DTZAppium\AppiumDTZ\AppiumDTZ\Test\Test_WorkOrderDetails.cs : line 87
Test Outcome: Failed
Test Duration: 0:00:00

Result Message: Assembly Initialization method AppiumDTZ.Test_LandingPage.testinitialisation threw exception. OpenQA.Selenium.WebDriverException: OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://127.0.0.1:4723/wd/hub/session timed out after 60 seconds. ---> System.Net.WebException: The request was aborted: The operation has timed out.. Aborting test execution.
Result StackTrace:
at System.Net.HttpWebRequest.GetResponse()
   at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
 --- End of inner exception stack trace ---
    at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
   at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
   at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
   at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities)
   at AppiumDTZ.InitialiseAppium.AppiumSetupMethod() in e:\QA automation\appium\AppiumTFS\DTZAppium\AppiumDTZ\AppiumDTZ\InitialiseAppium.cs:line 41
   at AppiumDTZ.Test_LandingPage.testinitialisation(TestContext context) in e:\QA automation\appium\AppiumTFS\DTZAppium\AppiumDTZ\AppiumDTZ\Test\Test_LandingPage.cs:line 24


The solution was add a time stamp to the place where you initialize the appium web driver or remote web driver or what ever the driver.
By default it has set to 60 seconds.


driver = new RemoteWebDriver (new Uri("http://127.0.0.1:4723/wd/hub"), capabilities,TimeSpan.FromSeconds(180));

Wednesday, May 4, 2016

Important things on CodedUI

If you need to add any costume text to your test out put.
just try adding highlighted text to your test method.


        [TestCategory("Work Order List"), TestMethod]
        public void Validate_WorkOrder_Search_By_Asset_Barcode()
        {
            ElemantsWODetails elm = new ElemantsWODetails();
            string WorkOrderAssetNumber = "QAZWSXEDC123";
            string ExpectedAssetBarcode=elm.ValidateSearchWOByBarcode("QAZWSXEDC123");
            Assert.AreEqual(ExpectedAssetBarcode, WorkOrderAssetNumber);
            elm.ClickOnDoneButton();
            this.TestContext.WriteLine("Expected Result :" + ExpectedAssetBarcode + "  Actual Result : " + WorkOrderAssetNumber + "");

        }

Out put.