Saturday 8 November 2014

Invoke Maven Project by - Jenkins !!



How to invoke maven project through Jenkins steps are below :-

1. Download and install jenkins.

2. Run jenkins.war by following command :-

java -jar jenkins.war --httpPort=9090
If you want to use https use the following command:
java -jar jenkins.war --httpsPort=9090

3. Create Jenkins Job:-

Create TestMaven Job


before creating job ensure that you set jdk path in jenkins configuration.


4. Set your POM.xml file path and build jenkins job :-









Done :)

For Creating Maven Project :- Link





Friday 7 November 2014

How To Create Maven Project !!


Here is the way to create way to create maven project :-

1.) Install Maven in your latest eclipse.

2.) Create Maven Project.

3.) Create Below Java file in package com under src/main/java -

package com;
import javax.swing.JOptionPane;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class TestClass {
   
     public static void main(String[] args) throws InterruptedException {
            // Create a new instance of the firefox driver
            // Notice that the remainder of the code relies on the interface,
            // not the implementation.
            WebDriver driver = new FirefoxDriver();

            // And now use this to visit Google
            driver.get("http://www.google.com");

            // Find the text input element by its name
            WebElement element = driver.findElement(By.name("q"));

            // Enter something to search for
            element.sendKeys("cheese!");

            // Now submit the form. WebDriver will find the form for us from the element
            element.submit();

            Thread.sleep(5000);
            // Check the title of the page
            JOptionPane.showMessageDialog(null, "Page title is: " + driver.getTitle());
                
            driver.quit();
        }

}

4.)  Edit your pom.xml

Here is edited  pom.xml :-

<project
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>kepler_maven</groupId>
    <artifactId>kepler_maven</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.44.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.1.1</version>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>com.TestClass</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

5.) Run pom.xml as Maven Install

6.) Here is the complete zipped project Maven Sample Project

Done !!