Thursday, November 14, 2013

Setup Selendroid on Windows.

LINK TO DOWNLOAD THE FILE WITH PICTURES


System requirements to run selendroid testcase on Windows.
  1. 1.       Java sdk (minimum 1.6) is installed and JAVA_HOME is configured.
     
       
  1. Set the Environment path:Set proper Environment path for Java

    • Right Click on My Computer->Properties
      • Select Advanced system Settings
        • Click on Environment Variables
          1. 4.       Click on New : Enter the below Variables and save as shown in screenshot.

          Variable name : JAVA_HOME  .Variable Value :C:\Program Files\Java\jdk1.6.0_26\ (This should be the path of JDK on the machine)

          Variable name : PATH .Variable Value :% JAVA_HOME%bin;
          1. 5.       Latest Android-Sdk is installed



          1. 6.        ANDROID_HOME is set.
          Variable name : ANDROID_HOME Variable Value : D:\InstalledSoftwares\ANDROID\
          Variable name : PATH .Variable Value :%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;
          1. 7.       At least one Android virtual device must be existent or an Android hardware device must be plugged in to the computer.
          Click on start->All programs->android SDK tools ->Launch avd manager
          Wait for it to open

          Click on new



          Fill in AVD NAME: for eg: SAMSUNG GALAXY, select Existing device and any target from the dropdown and click on OK.

          Android virtual device will be created.

          Now you are ready to launch selendroid testcases on this AVD.

           LINK to download the same blog with pictures

          Sunday, October 14, 2012

          Install Jenkins on Tomcat

          Hi All,

          To install jenkins on tomcat server,

          1.Download apache tomcat
          2.Download jenkins.war
          3.Copy jenkins.war in  apache-tomcat-*.0.**/webapps/ foler
          4.Navigate to  http://localhost:8080/jenkins
          5.You can see jenkins installed on Tomcat.

          Thursday, October 4, 2012

          Link to store the subversion credentials in jenkins

          When we have configured master-slave connection,we need to store svn credentials in both master and slave .Link appears to enter the credentials on master for jobs which runs on master,but link doesn't appears for the jobs tied to slave.Hence ,Auhentication failed error appears and svn checkout cannot be done.

          Below is the link which will help you to store the svn credentials on any jenkins .

          If  your jenkins is on localhost:8080 then,



          If you need to setup credentials on jenkins which is deployed on any webserver , then

          http://machinename:port/jenkins/scm/SubversionSCM/enterCredential
           where port is webserver's port number

          Wednesday, October 3, 2012

          Calling a java class as ant target

          Here is the way to do it

          classname: is filename of java :Ex: AutomationFileSequence
           arg: Any arguments if required to run the class needs to be mentioned here.

          <target name="run_PostData" >
            <java fork="false" failonerror="yes" classname="com.qa.automation.main.AutomationFileSequence" classpathref="classpath"> 
                      <arg line="${basedir}/Automation_PostData.properties"/>
              <arg line="PostData"/>
                      </java>
                      </target>

          Starting and stopping selenium server through ant

          Here is the way to do it.

          Start selenium hub:

          <target name="startServerhub">
                  <echo>Starting Selenium Server...</echo>
                  <java jar="${lib.dir}/selenium-server-standalone.jar" fork="true" spawn="true">
                      <arg line="-port ${selenium.port} -trustAllSSLcertificates"/>
                      <arg line="-log log.txt"/>   
                      <arg value="-role"/>
                      <arg value="hub"/>
                  </java>
              </target>

          Start selenium RC:

          <target name="startServerRC" depends="startServerhub">
                  <echo>Starting Selenium Server...</echo>
                  <java jar="${lib.dir}/selenium-server-standalone.jar" fork="true" spawn="true">
                      <arg line="-port 5555"/>
                      <arg line="-log log.txt"/>   
                      <arg line="-firefoxProfileTemplate"/>
                      <arg value="${lib.dir}/ff_profile"/>
                      <arg line="-userExtensions"/>
                          <arg value="${lib.dir}/user-extensions.js"/>
                      <arg line="-role node"/>
                      <arg line="-hub http://localhost:4444/grid/register "/>
                      <!--<arg line="-maxSession 10"/>
                      <arg line="-maxInstances=10"/>-->
                  </java>
              </target>


          Now ,save the targets in the file build.xml .navigate to the folder through cmd prompt and call



           ant startServerRC

          which will internally call startServerhub,since startServerRC depends on startServerhub.



          Stop selenium :

          <target name="stop-selenium" description="stop selenium server">
                  <echo>Stopping selenium server</echo>
                  <get taskname="selenium-shutdown" dest="result.txt" ignoreerrors="true"
                       src="http://localhost:${selenium.port}/selenium-server/driver/?cmd=shutDownSeleniumServer"/>
              </target>


          To stop selenium, call  : ant stop-selenium.

          Sample Ant Script for running targets parallel and sequential

          Recently ,I faced a challenge for making one target which can run the entire suite with lot of module dependencies.This was resolved with the help of ant targets: sequential and parallel.


          Requirement :
          I need to run the following sequetially

          1.compile target
          2. run and run_psdata targets paralelly
          3.run_PreData,run_DFPPulls,run_AdTechPulls.... parallelly
          4.run_PostData,run_Sales parallely
          5.run_Administration,run_E2EPartner360,..... parallelly
          6.run_Alerts,run_CustomFields  parallelly
          7.Stop selenium

          Below is the code to do all the above steps sequentially


          <target name="CItarget">    
                  <sequential>
                      <antcall target="compile"/>
                      <parallel>
                        <antcall target="run"/>
                        <antcall target="run_PSDATA"/>
                      </parallel>
                       <parallel>
                          <antcall target="run_PreData"/>
                          <antcall target="run_DFPPulls"/>
                          <antcall target="run_AdTechPulls"/>
                          <antcall target="run_AppnexusPulls"/>
                          <antcall target="run_FTPPulls"/>
                          <antcall target="run_OASPulls"/>
                          <antcall target="run_GDFPPulls"/>
                          <antcall target="run_FreewheelPulls"/>
                          <antcall target="run_ThirdPartyPulls"/>
                      </parallel>
              <parallel>
                  <antcall target="run_PostData"/>
                  <antcall target="run_Sales"/>
              </parallel>
                      <parallel>
                          <antcall target="run_Administration"/>
                          <antcall target="run_E2EPartner360"/>
                          <antcall target="run_Finance"/>
                          <antcall target="run_Loaders"/>
                          <antcall target="run_Accounts"/>
                          <antcall target="run_Adops"/>
                      </parallel>
                      <parallel>
                           <antcall target="run_Alerts"/>
                          <antcall target="run_CustomFields"/>
                      </parallel>
                      <antcall target="stop-selenium"/>
                 </sequential>
              </target>

          Monday, March 5, 2012

          Interview Questions for Automation Engineers

          1.Access Modifiers of JAVA
          2.Explain final finaly and finalize
          3.real example for abstract and interface
          4.Launch firefox driver using webdriver.
          ans: (driver driver = new firefox driver();)selenium selenium = new default selenium(driver,siteurl.com);
          5.how to handle file upload using webdriver:
          ans:Autoit /Sikulo\i
          6.which is the plugin in ie to find d locator
          ans: developer tool
          7. Major difference between selenium RC and selenium Webdriver?
          ans:Single origin policy 
          1.  WebDriver works at the OS/browser level:For instance, command type works at the OS level rather than changing the value of the input elements with JavaScript
          2.  It drives the browser much more effectively and over comes the limitations of Selenium 1.x which affected our functional test coverage, like the file upload or download, pop-ups and dialogs barrier or self-signed certificates problems
          3. Selenium RC, It ‘injects’ JavaScript functions into the browser when the browser was loaded and then used its JavaScript to drive the AUT within the browser. WebDriver does not use this technique. Again, it drives the browser directly using the browser’s built in support for automation.WebDriver drives the tests natively with the browser and emulates the Human interaction with website. Implementation differs on each browser’s.
          4.  Selenium 2.0 will provide both Selenium 1.x and WebDriver APIs.
          5. WebDriver is the name of the key interface against which tests should be written, but there are 11 implementing classes, listed as below:
            AndroidDriver, AndroidWebDriver, ChromeDriver, EventFiringWebDriver, FirefoxDriver,
            HtmlUnitDriver, InternetExplorerDriver, IPhoneDriver, IPhoneSimulatorDriver, RemoteWebDriver, SafariDriver.
          8.what is hashmap?
          9.Explain OOPS concept
          10.TestNG framework.(How to pass parameters to the test method)
          11. why static keyword is used in main declaration?
          12.what is difference between testng paralellism and selenium grid?
          13.There is a script which types abc in a text box.When we run the script on firefox,it types abc with no pause,whereas if we run it on ie, it types a pauses types b pauses,types c and pauses.Y is it so?
          ans: Using css instead of xpath might resolve the issue.
          14. What are the challenges faced in IE?
          ans:Lazy loading.
          15.Scenario: Clicking on a button opens a pop up with no title or text ,just the locator of the popup exists.How do you wait for the popup to disappear?
          ans:Wait for the text to be enabled on the main page.or check if the locator of the popup is still displayed on screen
          16. Scenario: Above scenario how can you handle if multi threading  is implemented.
               if(any component on the mainpage is disabled due to popup){ //pop up is available
          while(){
              waitforpopupto disappear
          }
          }

          qs: thread1 is in while(),control is given by cpu to thread2 to execute something else.until control comes back, popup might have come and disappeared .So, thread1 goes to infinite loop.

          What do we do in such situation?

          17. Some testcases fails due to sync issue even after providing explicit and implicit waits? how can we resolve this issue?

          18.How do we re-run testcases which failed only due to sync issue in testNG?

          Asked below in Amazon Interview:
          19.without using inbuilt function, find the index of 1 string in other string
          20.find the number is square root or not and find the sq root of any given number
          30.write testcases of above to test ur code

          Please provide your thoughts as comments..


          How to access display function of class b in classA
          if display function is static , if class a extends class B, if class A doesnt extend class B, if display function is private/protected.
          Program to remove duplicates in a array.
          How to disable one test method of a class.
          How to make one test run,only if pre-req test passes.
          How to run parallely in grid.
          how to setup jenkins using ant.
          knowledge on Unix?

          Wednesday, February 1, 2012

          Creation of Firefox profile for Selenium


           We use Selenium with firefox profile to test our JS functions in selenium console of firefox profile.

           Before we can create profile, take a backup of  firefox  so that the bookmarks and default settings of firefox won't vanish.

           Steps to take backup:
          1. For Windows 7 users, go to C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\ and copy the default folder and paste it some local directory.
          2.  Windows XP users,C:\Users\username\Application Data\Mozilla\Firefox\Profiles\ and copy the default folder and paste it some local directory.

          Steps to create profile.
          1.     Make sure all your firefox instance are closed
          2.     Click Start>Run(windows xp) or click start ,type in search (windows 7)
          3.     Type “firefox.exe -ProfileManager -no-remote”    or C:\Program Files (x86)\Mozilla Firefox\firefox.exe -ProfileManager -no-remote
          4.     Select “Create Profile” 
          5.    Click “Next”
          6.     Enter new profile name (i.e. selenium)   Optional:  Select a directory folder to store your new profile
          7.     Click “Finish”
          8.   Don't Select “Don’t ask at startup”
          9.    Click “Start Firefox” and configure settings ,  From “View\Toolbars” tab, uncheck “Bookmarks Toolbar”
                Right click from toolbar and click “Customize”
                Remove “Google search” by dragging it to the “Customize Toolbar” window
                From the “Customize Toolbar” window, click “Use Small Icons” check box then hit “Done”
                Click “Tools\Options” then set the following:
                a. “Main” tab
                - set Home Page to “about:blank”
                - uncheck “Show the Downloads..” option
                b. “Tabs” tab
                - Select “a new window” for new pages
                - Uncheck all warning options
                c. “Content” tab
                - uncheck “Block pop-up” windows option
                d. “Privacy” tab
                - uncheck all “History” options
                e. “Security” tab
                - uncheck all “Security” options
                - click “Settings” and uncheck all warning options
                f. “Advanced” tab
                - Uncheck “autoscrolling” option from “General” tab
                - uncheck “warn me …” and “Ssearch Engines”option from “Update” tab
                From “Tools\Add-ons” install the following:
                - Firebug: allows you to edit, debug, and monitor CSS, HTML, and JavaScript on your application under test
                - Selenium IDE: allows you to record, edit, and debug Selenium tests
                - From the address bar type “about:config” and add the following by right-click anywhere on the page and selecting “new”
                - extensions.update.notifyUser (type=boolean; value=false)
                - extensions.newAddons (type=boolean; value=false) 
          10.  Now , your profile is set. To restart the default firefox , close the firefox profile, and Click Start>Run(windows xp) or click start ,type in search (windows 7) . Type “firefox.exe -ProfileManager -no-remote”    or C:\Program Files (x86)\Mozilla Firefox\firefox.exe -ProfileManager -no-remote . Select default and then click on “Don’t ask at startup”
          11. Now you can see your default  firefox with all your bookmarks.
          If, by any chance, the bookmarks are gone,then follow,

          Steps to restore the default profile

          1.  Copy the default folder from the local directory  
          2. Paste it in C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\default.which will replace the default profile . 
          Steps to launch Selenium Server with the created profile
          1.   Go to the folder containingselenium server jar 
          2. Now start selenium server with firefox profile by giving the right location of profile     
            java -jar selenium-server.jar -firefoxProfileTemplate “<Selenium Profile Directory>”

             ex :  java -jar selenium-server-standalone.jar  -firefoxProfileTemplate "C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\jvme65u6.selenium"
          3.  To launch selenium test using profile through ant,
           <target name="startServer">
                  <echo>Start Selenium Server...</echo>
                  <java jar="${lib.dir}/selenium-server.jar" fork="true" spawn="true">
                      <arg line="-port ${selenium.port} -trustAllSSLcertificates"/>
                      <arg line="-log log.txt"/>   
                      <arg value="-userExtensions"/>
                          <arg value="${lib.dir}/user-extensions.js"/>
                  </java>
              </target>

          Any problems??? feel free to comment...

          Tuesday, January 24, 2012

          Integrating Selenium with jenkins/Hudson


           
          Integrating Selenium with Jenkins
          Jenkins is a build server designed for Java. Jenkins is responsible for checking if your application needs building, building it, triggering any testing that you have defined and, finally, reporting on the state of the build. Jenkins is easily available and can display JUnit reports in graphical format with drilldown capabilities.
          Download Jenkins
          Download Jenkins war from Jenkins website. Save it in one of our drive. For ex: D:\Jenkins.war
          Start Jenkins:
          Open command prompt and navigate to the folder containing jenkins.war and give java –jar jenkins.war
          You can see
          [Winstone 2012/01/25 08:46:47] - Beginning extraction from war file
          Jenkins home directory: C:\Users\username\.jenkins found at: $user.home/.jenkins
          [Winstone 2012/01/25 08:46:52] - HTTP Listener started: port=8080
          [Winstone 2012/01/25 08:46:52] - AJP13 Listener started: port=8009
          [Winstone 2012/01/25 08:46:52] - Winstone Servlet Engine v0.9.10 running: contro
          lPort=disabled
          Jan 25, 2012 8:46:52 AM jenkins.model.Jenkins$6 onAttained
          INFO: Started initialization
          Jan 25, 2012 8:46:53 AM jenkins.model.Jenkins$6 onAttained
          INFO: Listed all plugins
          Jan 25, 2012 8:47:25 AM jenkins.model.Jenkins$6 onAttained
          INFO: Prepared all plugins
          Jan 25, 2012 8:47:26 AM jenkins.model.Jenkins$6 onAttained
          INFO: Started all plugins
          Jan 25, 2012 8:47:26 AM jenkins.model.Jenkins$6 onAttained
          INFO: Augmented all extensions
          Jan 25, 2012 8:47:34 AM jenkins.model.Jenkins$6 onAttained
          INFO: Loaded all jobs
          Jan 25, 2012 8:47:34 AM jenkins.model.Jenkins$6 onAttained
          INFO: Completed initialization
          Jan 25, 2012 8:47:34 AM hudson.TcpSlaveAgentListener <init>
          INFO: JNLP slave agent listener started on TCP port 64776

          Jenkins  home directory will be created in C:\Users\username\.jenkins
          Check to see, if Jenkins is running
          Jenkins will be launched on port 8080, hence, open the URL http://localhost:8080/, to see the dashboard of Jenkins
          You can see,




          Create new project
          1.       Enter job name as SelAutomationCI
          2.       Select “build a free style software project”
          3.       Click OK
          Enter the details of repository
          4.       In the Source code management section, select the repository type and enter the repository location.




          Integrating Selenium with Jenkins:
          1.       In the Build Section, there are 4 options through which you can integrate your projects to selenium
          2.       In my project, I use ant as building tool which can run suite. (Check the blog, http://seleniumready.blogspot.in/2012/10/sample-ant-script-for-running-targets.html )
          3.       In build Option->Add build step, we need to select invoke ant CItarget



           
          1.       In the targets section, write the target which runs the suite. In our case: run
          2.       Click on Advanced.
          3.       Enter the  build file location in Build File field






          1.       In Post Build action section, Click on  Publish junit test results report and enter the location to store the results xml’s, as shown below.
          2.       Click on Email notification, to get the result of unstable builds, or build failure.
          3.       Click on Save.
          4.       To run the build, Click on build now.





          1.       the build History section, You can see the build number with the time stamp.






          .       Clicking on the build link, will show the console output.
          .       You can see selenium test running on Hudson.

          Monday, September 19, 2011

          Challenges faced in ext js

          Hi,
          I.m working on ext js application, whose speciality is,all the elements of the page are dynamic.This indicates that its not automation friendly.
          I'll post some of the locators which i used to locate elements.


          Selecting from drop down
          There is a select list, which contains a text box and down arrow image button, clicking on button image, opens a drop down which contains element with dynamic id's.
          Dynamic elements are : drop down elements (div's) , and image button.
           Clue is, input box has an id.

          This can be located as.

          //input[@id='abc']/following-sibling::img

          this clicks on image .now we need to select the dropdown list element , which also has dynamic id.
          So,i used text function as,

          //div[text()='CPA']

          which clicks on cpa in the dropdown list.

          Locating elements with same name ,based on their position using css

          I hadto locate 3 elements with same id.(Accounts). All had same name, no other unique identifier.

          So,i could locate them using,

          css=div#salestabs  td[class*=Accounts ]
          css=div#salestabs  td[class*=Accounts ]  div:nth(1)
          css=div#salestabs  td[class*=Accounts ]  div:nth(2)


          Css will locate element based on their parent element.The above css looks so simple, but the dom is so complex.

          div has class name x-combo-list-inner,under that


          <div class="x-combo-list-item">YYYY-Month</div>
          <div class="x-combo-list-item  x-combo-selected">YYYY-MM</div>
          <div class="x-combo-list-item  x-combo-selected">MM-YYYY</div>

          and then div closes(</div>)

          Another div having same class name and same list of combo items as mentioned above. is located below the above div.

           <div class='x-combo-list-inne'>
          <div class="x-combo-list-item">YYYY-Month</div>
          <div class="x-combo-list-item  x-combo-selected">YYYY-MM</div>
          <div class="x-combo-list-item  x-combo-selected">MM-YYYY</div>
           </div>

          this can be located as

          css=div[class*='x-combo-list-inner'] div:nth(2)---locates  3rd element of 1st div.

          css=div[class*='x-combo-list-inner'] div:nth(5)--locates 3rd element of 2nd div.


          Post will be continued as n wen i find more challenges.....