Thursday 20 August 2015

Get Microsoft Office/ Excel Name Function in Java

Retrieve Microsoft Excel Name and Office Path In JAVA


I have implemented an office name parsing function to reterieve which Office is installed in our machine. This code is written in Java and can be used to Automate Excel .. 

This function Performs Following Steps :

1) Find Office Excel Path Dynamically.
2) Open Excels
3) Parse the path to find which Excel is installed.

Note:- I have used parsing for Excel 2013, Excel 2010, Excel 2007 you can extend it for other office Names

public static String getofficeName()
    {
    Process p;
try {
p = Runtime.getRuntime().exec
     (new String [] { "cmd.exe", "/c", "assoc", ".xls"});

           BufferedReader input =
             new BufferedReader
               (new InputStreamReader(p.getInputStream()));
           String extensionType = input.readLine();
           input.close();
           // extract type
           if (extensionType == null) {
             System.out.println("no office installed ?");
             System.exit(1);
           }
           String fileType[] = extensionType.split("=");

           p = Runtime.getRuntime().exec
             (new String [] { "cmd.exe", "/c", "ftype", fileType[1]});
           input =
             new BufferedReader
               (new InputStreamReader(p.getInputStream()));
           String fileAssociation = input.readLine();
           // extract path
           String officePath = fileAssociation.split("=")[1];
           officePath = officePath.split("/")[0];
           System.out.println(officePath);
   
           if( officePath.contains("Root"))
  {
            String[] officePath1 = officePath.split("Root\\\\", 2);
            a = officePath1[1];
            a  = a.split("\\\\")[0];

            if (a.equalsIgnoreCase("Office15"))
            {
            OfficeName = "Excel 2013";
           
            else if (a.equalsIgnoreCase("Office14"))

    {

    OfficeName = "Excel 2010";
   
            
        else if (a.equalsIgnoreCase("Office12"))

    {

    OfficeName = "Excel 2007";
    }
    }
    else
    {
    String[] officePath2 = officePath.split("Office\\\\", 2);
    a = officePath2[1];
    a  = a.split("\\\\")[0];

    if (a.equalsIgnoreCase("Office14"))

    {

    OfficeName = "Excel 2010";
    }
   
    else if (a.equalsIgnoreCase("Office15"))
        {
        OfficeName = "Excel 2013";
       
    else if (a.equalsIgnoreCase("Office12"))

    {

    OfficeName = "Excel 2007";
    }
   
    }

      }catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
       
return OfficeName;

 }
    

Wednesday 12 August 2015

Sikuli With Java For Testers

Sikuli With Java For Testers

Introduction:

Sikuli is an open source tool to automate and test graphical user interfaces (GUI) using images (screenshots).

As, Sikuli is based on image recognition, it waits for anything to appear on screen and, click, type etc. according to the specified identifiers. The identifiers are specified by images. Sikuli triggers GUI interactions based on the image visual match, the image which we have passed as the parameter along with all methods.

For example, if there is a Flash component on the web page with a "Next" button, an image of the "Next" button could be captured using the Sikuli, and stored. Then with the Java code the "Next" button could be identified and clicked. In-addition, the core of Sikuli Script is written in Java, which means you can use Sikuli Script as a standard JAVA library in your program.

Sikuli Can Be Useful When:

  1. When we are testing Legacy apps which are designed without a thought towards testability and thus ids were not specified by the developer
  2. When we have to be particular about UI which has lot of images and flash content on the webpage
  3. When we have to deal with an application like Google maps, Excel
  4. It can also be used to test non-browser GUI applications

    Common Functions of Java I Used In Sikuli Framework

1)Absolute Path



2) CSV Read Functions...




3) Send Email Function




Prerequisite

1. Download and install sikuli from for more information visit link "http://www.sikuli.org/download.html 
2. Download and install java 1.6
3. Download and setup eclipse with Test NG

I have created a sikuli script in which I open notepad, type some text and save file into system.

Step by Step working

1. Create a java project in to your eclipse.
2. Add "testng.jar" and "sikuli-script.jar" to your eclipse library.
3. Create a images folder into your java project as below.  
4.  Get images of using Sikuli IDE and put into images folder.
5. Create a java class into src folder.
6. Import sikuli classed and create Screen class object. as below java code:

package com.test;

import org.sikuli.script.App;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Screen;
import org.testng.annotations.Test;

public class SikuliTest {

    public Screen screen;
    
    @Test
    public void tesSikuli() throws InterruptedException, FindFailed
    {
        //open note pad application
        screen =new  Screen();
        App.open("notepad.exe");
        Thread.sleep(2000);
        
        //type text notepad
        screen.type("images/InputFiled.png", "Testing sikuli with Test NG");
        Thread.sleep(2000);
        
        //click on file menu
        screen.click("images/FileMenu.png", 20);
        Thread.sleep(2000);
        
        //click on save submenu
        screen.click("images/SavesubMenu.png", 20);
        Thread.sleep(2000);
        
        //select file input field and type path 
       screen.click("images/FilePathInput.png", 20);
        screen.type("images/FilePathInput.png", "C:\\test.txt");
        Thread.sleep(2000);
        
        //click save button
        screen.click("images/SaveButton.png", 20);
        Thread.sleep(2000);    
        
    }
}

7. Right click on eclipse test scripts and chose Run As > TestNG Test and click.
8. After successfully run you can see eclipse console log as below screen.


Tuesday 6 January 2015

Selenium Testing Important URLs



http://www.mkyong.com/



http://whytotest.blogspot.in/2010/05/selenium-test-framework.html

http://anoopjshetty.wordpress.com/2012/04/19/behaviour-driven-development-bdd-in-net-using-specflow-selenium-and-nunit/

http://codedetective.blogspot.in/2011/11/setting-up-selenium-webdriver-using-c.html

http://help.utest.com/testers/crash-courses/functional/automation-tools--selenium-102

http://www.savevid.com/video/selenium-video-training-datadriven-framework-and-hybrid-framework-comparison.html

http://testng.org/doc/index.html

http://selenium-tutorial.blogspot.in/2012/04/uploading-file.html

http://oxpedia.org/wiki/index.php?title=Automated_GUI_Tests

http://xebee.xebia.in/2012/05/29/creating-automation-framework-using-selenium-and-test-ng-2/

http://www.way2automation.com/selenium_tutorial/selenium-hybrid-datadriven-keyword-framework

-tutorial.html

http://www.seleniumwiki.com/selenium-rc/selenium-keyword-driven-framework/


http://executeautomation.com/blog/blog_mod/data-driven-testing-in-selenium-using-jxl-part-2/

http://code.google.com/p/selenium/wiki/AdvancedUserInteractions

http://www.kavinschool.com/content/selenium-tuition-bayarea/39-selenium-course/54-advanced-s

elenium-using-java-language

http://www.ijcst.com/vol23/1/prasanth.pdf

http://code.google.com/p/selenium/wiki/PageFactory

http://learnseleniumautomation.blogspot.in/2012/03/window-handle-example-with-selenium.html

http://www.ibm.com/developerworks/web/library/wa-seleniumgrid/index.html

http://www.8bitavenue.com/2012/03/gui-testing-using-sikuli-and-java/

http://eureka.ykyuen.info/2010/06/26/selenium-integrate-the-selenium-tests-into-maven-build/

http://www.way2automation.com/

http://mearra.com/blogs/jani-palsamaki/creating-and-running-simple-selenium-webdriver-test

http://code.google.com/p/selenium/wiki/SeleniumEmulation

http://automation.youplayoff.com/category/selenium/


http://qaselenium.blogspot.in/2011/01/selenium-automation-framework-design.html

http://seleniumexamples.com/blog/examples/selenium2-in-net-framework/

http://robotframework-seleniumlibrary.googlecode.com/hg/doc/SeleniumLibrary.html?r=2.8

https://blogs.oracle.com/rajeshthekkadath/

http://en.wikipedia.org/wiki/Selenium_%28software%29

http://www.f14testing.com/archives/1532

http://functionaltestautomation.blogspot.in/2009/10/dataprovider-data-driven-testing-with.html

http://www.javacodegeeks.com/2012/04/integration-testing-with-selenium.html

http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/html5/package-summary.html

http://sauceio.com/index.php/2011/12/selenium-testing-framework-part-3-putting-it-all-togeth

er/

http://selftechy.com/2011/06/02/parameterization-of-selenium-tests-with-microsoft-excel

http://sauceio.com/index.php/2011/11/selenium-testing-framework-pt-2-base-classes/

http://www.kavinschool.com/content/selenium-tuition-bayarea/39-selenium-course/54-advanced-s

elenium-using-java-language

http://hop2croft.wordpress.com/2011/09/17/spring-mvc-basic-example-with-maven/

http://www.seleniumwiki.com/selenium-rc/selenium-rc-test-framework-using-xml-data-structure/

http://marcovaltas.com/2009/02/19/running-selenium-with-testng.html

http://blog.varunin.com/

http://en.wikipedia.org/wiki/Data-driven_testing

http://thangselenium.blogspot.in/


http://sqahome.blogspot.in/2010/06/selenium-framework-structure-java.html

http://www.wallix.org/2011/07/26/how-to-use-robotframework-with-the-selenium-library/

http://qtpselenium.com/selenium-tutorial/selenium-training-hybrid-framework/

http://automationtestingsimplified.wordpress.com/2011/08/18/how-to-do-data-driven-testing-us

ing-selenium-2-webdriver/

http://wiki.zimbra.com/wiki/Testing:_Selenium:_ZimbraSelenium_SampleTestCase

http://code.google.com/p/selenium/wiki/PageObjects

http://marakana.com/bookshelf/selenium_tutorial/project.html

http://in.linkedin.com/pub/selenium-rc-webdriver-tutorial/51/b7/49

http://code.google.com/p/robotframework-seleniumlibrary/

http://blog.codecentric.de/en/2010/07/file-downloads-with-selenium-mission-impossible/

http://www.pushtotest.com/testing-with-selenium#tutorial

http://seleniumrc.wordpress.com/

http://qtp-help.blogspot.in/p/selenium-training.html

http://www.seleniumtests.com/2012/01/selenium-2-methods-are-no-more-weird.html?utm_source=BP_recent

http://candidjava.com/keyword-this-in-java-with-example-program

https://github.com/Ardesco/Ebselen/blob/master/ebselen-core/src/main/java/com/lazerycode/ebselen/customhandlers/ExcelHandler.java

http://shanmugavelc.blogspot.in/2010/09/datadriven-test-using-selenium-nunit.html

http://vimeo.com/46412735

http://computer.motiontopic.net/s/Selenium-Data-driven-framework

Selenium Grid

http://code.google.com/p/selenium/wiki/Grid2
http://deors.wordpress.com/2012/02/02/selenium-webdriver-grid-2/
http://technologyandleadership.com/30-feet-view-of-test-automation-framework-with-selenium/

selenium with flash

http://code.google.com/p/flash-selenium/


http://www.softwaretestingtutorials.org/packages/


selenium with ant

http://hedleyproctor.com/2011/07/automating-selenium-testing-with-testng-ant-and-cruisecontrol/


selenium Index

http://www.sqaforums.com/showflat.php?Cat=0&Number=716574&Main=714887

http://www.citehr.com/374186-best-institute-learning-selenium-testing.html

http://forum.softwaretestinghelp.com/index.php?topic=446.0

http://grokbase.com/p/gg/selenium-users/125bve6d3m/is-anyone-provide-me-code-for-data-driven-testing-in-selenium-webdriver-in-java-junit-framework-plz-it-is-urgent

http://ahmedabad.olx.in/selenium-training-in-ahmedabad-iid-249982843


http://www.automation.lifegoeasy.com/Selenium-Webdriver-Java-Syllabus

http://seleniumtraining.weebly.com/selenium-automation.html

http://www.360logica.com/test-automation-services/functional-automation-framework


Testng

http://ravisha-selenium.blogspot.in/

DataDriven framework

http://executeautomation.com/blog/tag/data-driven-testing/

http://functionaltestautomation.blogspot.in/2009/10/dataprovider-data-driven-testing-with.html

http://qtpselenium.com/selenium-tutorial/selenium-training-data-driven-framework/

http://automationtestingsimplified.wordpress.com/2011/08/18/how-to-do-data-driven-testing-using-selenium-2-webdriver/

http://automationtestingsimplified.wordpress.com/2011/05/31/hybrid-testing-data-keyword-driven-using-selenium/

http://www.softwaretestingclub.com/video/selenium-data-driven-automation-framework-selenium-rc-junit

http://testerinyou.blogspot.in/2010/10/how-to-do-data-driven-testing-using.html

http://www.seleniumelearn.com/free-selenium-training-tutorial-videos

http://www.seleniumwebdriver.com/webdriver-tutorials/advance-selenium-rc-webdriver-tutorials-with-frameworks/msg16333/?PHPSESSID=b0af0d93c11942fedcc8c26d0ac04ec0#msg16333

http://lrnselenium.com/?category_name=automation-framework

http://selenium-suresh.blogspot.in/2012/07/data-driven-testing-using-selenium-rc_24.html

http://hedleyproctor.com/2011/07/automating-selenium-testing-with-testng-ant-and-cruisecontrol/

http://testingchronicle.blogspot.in/2012/05/selenium-keyword-driven-and-data-driven.html

https://sites.google.com/site/joinqahub/Selenium-tutorial-for-beginners

http://executeautomation.com/blog/blog_mod/data-driven-testing-in-selenium-using-jxl-part-2/

http://www.gcrit.com/forums/viewtopic.php?f=29&t=109
http://zomobo.net/keyword-driven
http://www.youtube.com/watch?v=KL4Y7cWiK4g&feature=player_embedded
http://www.youtube.com/watch?v=JMZeaF0ST4w&feature=channel
http://www.youtube.com/watch?v=1ZV8pZAKkDQ&NR=1
http://www.youtube.com/watch?v=A6ND9pRRBY8&NR=1

http://www.whatsontv.co.uk/video/youtube/search/keyword-driven

Get Microsoft Office/ Excel Name Function in Java

Retrieve Microsoft Excel Name and Office Path In JAVA I have implemented an office name parsing function to reterieve which Office is in...

Get Counted