Monday, 24 November 2014

One click execution in Selenium Web Driver



Creating executable file for running the entire test suite using ANT.(One click execution in selenium web driver)
 
    1.       We have seen how to run all tests and generate reports and later email the reports. 

    2.       Now I want to execute all commands and run the entire project in 1 click.
  
     3.       For that I have to create a notepad and write the following commands (targets in build.xml).
   
     4 .     Copy paste below lines in a note pad and later save it with .bat extension.

d:
D:\Workspace\TestProject
ant -f testbuildname.xml clean junitreport sendMail

    5.       Here ant,clean,junitreport and sendMail are targets specified in your build.xml.

    6.       You can directly double click on this file and the entire suite would be executed.


    7.       After successful execution of the suite, results will be emailed to your id.

Friday, 21 November 2014

Email Zipped Reports in Selenium Webdriver using ANT



Email Zipped Reports in Selenium Webdriver using ANT

 1.       For generating ANT Reports refer link

 2.       For Generating Zipped reports using ANT build.xml refer link

 3.       Add javax.mail.jar.zipand javax.activation.jar.zip to your ${ANT_HOME} lib folder.

 4.        Also add Javax.mail and Javax.activate jar in class path of Ant. Go to Window–> Preferences –> Ant (Click on triangle icon to expend Ant options) –> Click on Runtime –> Select Classpath tab –> select Global Entries –> Click on Add external jar and add above mentioned jar and click ok and then select the build.xml and run as you are trying to run your program and it will work..

 5.       For emailing the reports, add the following code to build.xml

 <target name="sendMail" depends="junitreport,addZip">
                      <mail mailhost="smtp.gmail.com" mailport="465" user="archana@gmail.com"
                          password="abc123" ssl="on" messagemimetype="text/html"
                          charset="ISO-8859-1" subject="Test Results"
                          tolist="archana@gmail.com">
                          <from address="archana@gmail.com"/>
                          <message>
                              Please view index.html page for report in attached zip.
                          </message>
                          <fileset dir="${zip}"/>
                      </mail>
                      <echo> Mail is sent successfully </echo>
                  </target> 
     
 6.       Copy paste the above code and replace your email id and password.

 7.       The ${ZIP} folder is the path where your zip file is generated.

Zip Junit Html ANT Reports in Selenium Web driver



Zip Junit Html ANT Reports in Selenium Web driver

1.       Create the build.xml for the project by which we can generate ANT reports.

Detailed description of creating Junit ANT Reports is given in this post.

2.       Now add the below code to the Build.xml to create a zip file in the folder location.

    <target name="addZip">
                <zip destfile="${zip}/testReport.zip" duplicate="preserve">
                    <zipfileset dir="D:\Workspace\TestProject\junit" />
                     </zip>

Here the name of the “destfile” should be the folder where reports should be created and name of the zip file.
The “zipfileset” should be the folder location where junit ant reports are generated.