Blog to understand automation concepts in QTP, Selenium Webdriver and Manual Testing concepts

Tips to handle first hurdles using selenium webdriver on IE browser

Some useful tips while launching tips in launching browser:

          HurdleGet following error on launching the IE browser:
Exception in thread "main"org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information).


In case such error is displayed in the console, it is asking to set same protected mode setting for all the zones. This can be set as shown in screenshot below:



 Hurdle:  Some Websites especially in QA environment do not have proper certificates installed due to which we get an error Page with issue with security certificate. Once user clicks on Continue to this Website (not recommended), a pop up appears. How to handle the pop up window?



Usually in QA environment, on navigating a page is https://, certificate error is displayed. The links in the Page are identified easily using selenium, but the pop up is not handled properly using alerts as:
Alert alert = driver.switchTo().alert();
alert.accept();

Alerts are used to handle javascript alerts that pop up in between.
Alerts can be used to accept a pop up, dismiss a pop up,getText(),SendKeys.

I tried to handle the pop up for res://ieframe.dll/ using alerts, but it did not work out. On further trying, I find a simple solution to the solution. The solution to the problem is to add res://ieframe.dll/ to the trusted sites or local intranet.

       Hurdle: Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Browser zoom level was set to 150%. It should be set to 100% (WARNING: The server did not provide any stacktrace information


This error occurs in case the zoom level is set different from 100% zoom level.

So to consolidate, before running any test in IE, we should ensure :
      a.      Protected mode is set same for all the internet zones and
      b.      Zoom level is set as 100% in the IE browser.

     How do we maximize the browser on launching the browser?


Using  below code , we can maximise the browser:

WebDriver driver;
File file = new File("D:\\Selenium\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath()); 
driver = new  InternetExplorerDriver();
driver.manage().window().maximize();

Creating first test in Soap UI/Ready API


In this article, We will discuss on how to create a test in SOAP UI. Before starting, we need to discuss what SOAP UI is.  SOAP UI is web service testing application for SOA and Rest. Below is the step by step process and each step is described in detail to as to enable user able to create first tests in SOAP UI/ Ready API. We will discuss on following in this article                                                   

1.   Creating first project in SOAP UI

2.   Creating a test suite.

3.   Adding test case in the test suite

4.   Adding test steps to test case.

5.   Executing the test case.



1.   Creating first project in SOAP UI


a.    A new project can be created using menu Option File>Create a new Project or pressing Ctrl + shift + N.


b.   A new project Window appears to create a new project. Select the required option. Since in this example, we are creating a project from WSDL file, I have selected the option to import project from a WSDL definition (SOAP). Click on Ok.

c.   In New SOAP Project, Provide the URL /Path of WSDL and Name of the Project

d.   User can opt for creating sample request for operations in the WSDL and creation of a test suite for the Project.


2.   Useful  Setup information at Project level


a.   There are some project specific properties. Together with Project Properties, we can define custom properties that are used across test suites or requests in the test.
b.   We can define the endpoints and custom properties of different environment at project in case we have different environment on which we need to test the application.

c.   We can define the users in WSS-configuration to use the username/Password to access operations in the soap.


3.   Once a project is created, we can create a test suite in the Project.  A test suite contains a collection of test cases. Each test case consists further of test step. There can be multiple test suites in the Project. We can provide custom properties at the test suite similar to project and can set the environment to run the test suite.

4.   Inside a test suite are test cases. At test case level we define the test steps which are created to be executed. Below are some of the useful test steps in a test case:


a.   Data Source – To create a data driven test in soap UI, We create a data source.
b.   Data Source Loop – To loop through the steps in the test case from target step.
c.   Properties – Sets properties to be used in the test.
d.   Groovy Script – Groovy script to generate output from a script
e.   SOAP request – Adding a soap request in the test
f.    Property transfer – Transferring property value from the response to  data sink
g.   Data Sink – transferring value from test to external file.
h.   Delay – Delaying the execution by millisecond

5.   In Soap request, we can define assertions in the test to validate if the response from the request is valid and as expected.



All about working with browser object in QTP

This article discusses some useful code snippets working with browser object in QTP and useful tips while working with browser in QTP.

1.  How to launch a webpage in any of the browser.

Well, there are multiple ways to launch a webpage in browser of choice

a.  Using Systemutil command - SystemUtil.Run is an inbuilt QTP command used to launch an application. We can launch a browser using Systemutil as:

                  SystemUtil.Run "Chrome.exe", “http://www.thoughtscollectionme.blogspot.in/

Using systemutil.run we can launch other application, e.g.: we can open a word document

                  SystemUtil.run “winword.exe”, “C:\meraword.docx”

Other methods for Systemutil command are:

CloseProcessByName: Closes the process based on the name of the process. E.g.: If we want to close chrome in the machine, we can use:
                 SystemUtil.CloseProcessByName "chrome.exe"

CloseProcessByHwnd: Closes the process based on the window handle of the process.
                  SystemUtil.CloseProcessByHWND handleid

b.  Another method is to launch the browser using Wscript.shell object. The code to launch the application using wscript.shell object is as follows:

                 Set objShell = CreateObject("Wscript.shell")
                 objShell.run “chrome.exe  http://www.thoughtscollectionme.blogspot.in/
                 set objShell = Nothing

    2. How to know how many browsers instances are open at a particular instance:

We can get the number of open instance of browser using below function
  Function getbrowsercount()
               ‘’Create an object of description class
              Set objBrowser = Description.Create
             ‘’ We have created an description object with micclass as browser
             ObjBrowser(“micclass”).Value = “Browser”
            ‘’objbr stores collection of objects which matches property of micclass as browser
             Set objbr = Desktop.ChildObjects(ObjBrowser)
           ‘’ return the count of browsers in the function itself.
            getbrowsercount = objbr.count
            End Function

3. How to know the title of each of the  open browser

     Set objBrowser = Description.Create
    ObjBrowser(“micclass”).Value = “Browser”
    Set objbr = Desktop.ChildObjects(ObjectBrowser)
    getbrowsercount = objbr.count
    For i= 1 to objbr.count
   ’’Loop through each of the browser and print the title of browser in message box
            Msgbox objbr(i).getRoproperty(“title”)
    Next

    4. Now we need to close all the open browsers?

  ‘’We use ordinal identifier to identify an test object by assigning a numerical    value which indicates object’s  location or order relative to its group. Different types of Ordinal identifier are:
·         Index
·         Location
·         CreationTime.
While Browser(“Creationtime:=0”).exist(0)
Browser("creationtime:=0").Close
Wend

 5. How to close all browser except Quality Center?

When we run a test in QTP, we do not require QC to close but other browsers to close. The code can easily be derived using the codes explained above.
The code will be something like:
Function CloseAllbrowsersExceptIE(browsertitle)
Set objBrowser = Description.Create
objBrowser("micclass").Value = "Browser"
'Get all browsers
Set objBrowserLst= Desktop.ChildObjects(objBrowser)
For i=0 to objBrowserLst.count-1  
 'Verify the title of the browser contains "Quality Center"  
If InStr(objBrowserLst(i).GetROProperty("title"), "Quality Center”) = 0 Then
                                objBrowserLst(i).close  
            End If  
            Next 
Set objBrowser = nothing
Set objBrowser = nothing
End Function

6. Next question is how to close only a particular browser only and keeping the other browsers open.


The code is very much similar to above problem where we close all the browser except QC.
Just need to change the if statement in the code above:

If InStr(objBrowserLst(i).GetROProperty("title"), "Quality Center”) = 0
to
If InStr(objBrowserLst(i).GetROProperty("title"), "Quality Center”) > 0

will close only the particular browser and keep the other browser open.