P3selenium Framework Configuration Steps

Here we will see the Configuration Steps of P3selenium.

 

Precondition:
Java should be installed in the system
TestNG and Maven should be installed in eclipse

NOTE: We are using “Eclipse Juno” in this example

Configuration Steps:
You can get P3selenium framework from Github, use the following URL to download the zip
https://github.com/AbhishekAggarwal/p3selenium

Step 1: Extract the zip file and put it in your workspace
Step 2: Open Eclipse IDE.
Step 3: Go to File > Import
Step 4: Import window will open, select Existing Projects into Workspace under General category

Import

Step 5: Now to run different tests you have to make an entry in testng.xml file. Below is the testng.xml file used in p3selenium framework

Step 6: To run the test, right click on the project go to “Run As” > Maven test.
NOTE: When you run the project first time it may take time because it will download some required jar files.

Step 7: Now, we have to see the reports.
Reports will get generated at the end of the test execution and to see the reports you have to open the index.html file which is under target>surefire-reports>html>index.html

Cloning Git Repository in Eclipse

Cloning Git Repository in Eclipse is very easy. You can add any Git repository in Eclipse.

In this post, we will make a clone of existing Bitbucket repository in Eclipse Juno.
 
Follow the below steps:
Assuming that you have created a repository on Bitbucket

Step-1: Open Eclipse and check if your eclipse has the Git perspective or not
If not it does not have the Git perspective then follow step 2 else you can directly go to step 3

Step-2: Go to Help > Eclipse Marketplace
Type Git in Find field and install EGit
Marketplace

Step-3: Open Git perspective , Window > Open Perspective > Other > Git
Git

Step-4: Open your repository and copy the GIT URI
Here is a screenshot of Bitbucket repo
Git Repo

Step-5: Click on “Clone a Git repository”
Now give the in copied URI in the URI field, other fields automatically gets filled.
Now give the password and click Next.
Clone Git Repo in eclipse

Step-6: Branch Selection
The Repository is empty so no branch is displayed. Here, again click Next

Step-7: Local Destination
Here give the Directory where you want to clone the repository
I have given the path of my “eclipse workspace/repo name” or “D:\PROGRAMMING\Eclipse\clone-git”
local destination

Step-8: When the cloning finishes you will see Git Repository.
Now import project
Import Project

Now you can Import existing project or you can Use the New Project Wizard
Here we will create a new project using New Project Wizard and push it to the repository
Import

Step-9: Create a new project.
New Project

Step-10: Once the project has been created, you will see the project in the Explorer
Project Explorer

Create classes and code as you do.
and to push your code to the repository

Step-11: Right click on the project > Team > Commit
Select all the files that you want to commit and give the commit message. Then Press Commit and Push
commit

And you are done.

Check you can see the code in the source tab of the repository.
git source

Eclipse Shortcut

Some Random Eclipse Shortcuts

Today during searching over internet I found something interesting and I am more interested to share.

1. Ctrl+f irritates you when you have to search a word in eclipse?

Alternative:
* Press Ctrl+j(you will see “Incremental Find” start appearing at the bottom of the IDE)

Incremental Find

* Then write the word that you want to search(the word you type will not appear on the screen).
* Now press Ctrl+j again and again to search

Wrapped Hello

2. Eclipse shortcut for System.out.println(“”);

For the java programmers those who write the print statement many times in a day, you can use the trick
Trick: Write “syso” and then press Ctrl + space

3. Shortcut to write
public static void main(String[] args) { }

write “main” then press ctrl + space
 
Below are the some other links for Eclipse Shortcut:
http://www.vogella.com/tutorials/EclipseShortcuts/article.html
http://eclipse.dzone.com/news/effective-eclipse-shortcut-key
http://www.shortcutworld.com/en/win/Eclipse.html
http://javapapers.com/core-java/eclipse-shortcuts/

struts2 spring file structure

Struts2 Spring Hello World in Eclipse

Following example shows the integration of Struts2 ans Spring using ant in Eclipse
Using struts v-2.3.4.1 and spring v-3.2.0

File Structure
struts2 spring file structure

—index.jsp—

—Welcome.jsp—

—applicationContext.xml—

—User.java—

—struts.xml—

—web.xml—

OUTPUT:

output1
output2

Get the complete code with all the jars included. Enjoy

Main Class

How to create an executable jar file using eclipse

You can do this by using eclipse.

Step 1: Create a project. I have created a project with name “autorun”

Step 2: Right click on project > select Export
You will see export options select JAR file, then click next

jar export
 
Step 3:
Select the resource to export. Give export destination.

jar file specification
 
Step 4: Click Next.

Step 5: Specify the “main class” that you want to execute when someone clicks on the jar file (it is a starting point) , then Click Finish

Main Class

Done. Now Double click on the jar and it will run.