Prerequisite/Setup for Automation-Selenium/Appium/API using JAVA Maven Project

                     Automation Setup

Contents:


Details regarding JAVA and MAVEN setup along with environment path setup in windows which will help us when we will start writing automation scripts using JAVA either in SELENIUM - Web Automation, APPIUM-Mobile Automation and WEB Services automation using REST Assured .

We will be using TestNG framework to write our automation scripts and also we will see how we can setup TestNG in our eclipse IDE(this IDE we will be using to write our scripts).


  • Go to this Download and click on Windows Offline (64-bit) highlighted below if your machine is 64 bit or else just click on Windows Offline link as shown below:
            
  • Once .exe file gets downloaded, double click on it and install it in your system
  • After installation completes, open command Prompt and type java -version and click enter button, as shown below:
                    

  • If you will not able to see Java version in response then just go to C:/ drive > Program Files>Java> and then go to jdk folder and Copy this Path
  • Go to start menu in your computer and type environment and you will get below screen:
                   
  • Click on Edit the system environment  and you will get below screen:
                   

    
  • Click on Environment Variables... and you will see below screen:  
                   

  • Click on above highlighted New button and you will get prompt with below popup:
                    
  • Enter JAVA_HOME in Variable name filed and the path we copied in earlier steps should be entered to Variable value field.
  • Click on OK button.
  • Now search for path variable in Environment variable popup and click on Edit button as highlighted below:
                    
  • Now again click on New button displayed at top right corner of below screen and add this at the bottom i.e %JAVA_HOME%\bin - as shown in below snapshot:
                    
  • Now click on OK.
  • Now open command prompt and type java - version and you will able to see the below response 
                    

Install Maven in windows and environment setup in windows machine

  • Download maven zip file :  Download Zip
  • Extract the above downloaded zip file
  • Now copy the maven location where you have extracted it and do below steps similar to what we have followed while setting up environment variable for java. i.e. M2_HOME=C:\Users\kranjan\Maven\apache-maven-3.6.3                                                        and %M2_HOME%\bin
                   

and 

                    

  • Now open command prompt and type mvn -version
                    


Setup Eclipse-IDE for JAVA

  • To download IDE click on below link:
            Eclipse Neon 3.0 IDE
  • Once the above file will get downloaded, extract it and go inside the folder. Folder will contains many files as shown below:
                    

  • Now double click on the above highlighted eclipse.exe, it will open as shown below:
                    
  • Now in Workspace filed you need to provide the folder path where you want to create JAVA project. i.e. Create one folder in your computer anywhere and provide the same path. for example: C:\Users\kranjan\Desktop\EclipseDemo and click on OK button. Eclipse will launch successfully and you will see the below window:
                    
  • Un-check Always show Welcome at startup and close this from the highlighted close icon at top left corner of above screen. You will end with something displayed below:
                    



Install TestNG in Eclipse

  • Click on Help and select Eclipse Marketplace.. as highlighted in below snapshot
                   

  • Now in search box , type testng and click Enter button, below search result will be displayed:
  • NOTE: If you will not able to find testng in market place then skip below 2 steps and follow the steps mentioned.
        
  • For me it is showing installed, but for you it will be install. Just you have to click on Install> Accept licence and click on install. Once installation gets completed you re-start eclipse. Now to cross verify again to market place and search for testng and you will see Installed button instead of Install

Now if you will not able to search testng in Market place then follow the below steps:

  • Click on Help and select Install New Software...
        
        
  • Now select all the check boxes as shown above, click on next and select install after accepting term and conditions.
  • By above steps our TestNG setup will get completed. 

Create Maven Project

  • Launch Eclipse, go to File >New>Project..
        
  • Type Maven in Wizard window and select Maven Project as shown below
        
  • Just click on Next option in New Maven Project window as shown below:
            
  • In next screen just select maven-archetype-quickstart and click on Next option as highlighted below:
              
  • In Next window, enter api.automation in Group Id field and demo in Artifect Id
Note: You can give any name instead of api.automation and demo.

              
  • Click On Finish option displayed at the bottom in above snapshot.
  • As soon as you click on Finish option, one demo maven project will get created in the eclipse, as shown below:
                
  • Double click on pom.xml file to add dependencies, as shown below:
                
  • By default, the junit dependency will already be added as highlighted above. Here we need to add all the dependencies mentioned below which will help us in API automation as shown below:
                
  • We have added testNg dependency under dependencies tag as highlight above.
    
Like wise, you need to add other dependencies which all are mentioned below.

Here we have completed Maven project setup.

Comments