Sunday, July 23, 2017

Code to open firefox with selenium 3.4 using GeckoDriver 1.8


package test;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class testing {

    public static void main(String[] args) throws InterruptedException {
 // Download the geckodriver based on the firefox if it is 32 bit or 64
 // bit installed in the machine
 // Save the driver and provide path of the exe for geckodriver
 System.setProperty("webdriver.gecko.driver", "E:\\Selenium\\geckodriver-v0.18.0-win64\\geckodriver.exe");
 // define the capabilities of firefox browser with marionette set as true
 DesiredCapabilities capabilities = DesiredCapabilities.firefox();
 capabilities.setCapability("marionette", true);
 // create an instance of firefox driver
 WebDriver driver = new FirefoxDriver(capabilities);
 driver.get("http://www.rediff.com");
 driver.quit();
    }
}

Saturday, July 22, 2017

Switch between Windows using switch to in Selenium


String MainWinHandle = driver.getWindowHandle();
for(String NewWinHandle : driver.getWindowHandles()){
// Ignore the parent window open and work with the new window frame
 if(!NewWinHandle.equals(MainWindowHandle))
  {
    driver.switchTo().window(NewWinHandle);
 //Perform the required tasks to be performed in the new window opened
 driver.close();
 }
}
//Perform action on the main window once the task is completed with the old window.
driver.switchTo().window(MainWinHandle);

Thursday, July 20, 2017

Job creation in Jenkins: Workflow

Below are the steps to create a new job in Jenkins:

1. Launch Jenkins by providing the url and port number of Jenkins Server. 

2. Click on New Item to create a new Jenkins Job. Provide the jenkins Job Name and select the project type. Let us select a freestyle project.

New job Jenkins
3. There are different sections in the jenkins Job which are shown below.

4. Below Flowchart explains the different information we can provide in a jenkins job and what is the role of different sections in a jenkins job.Jenkins job creation workflow

5. General Section:Job Description is provided in this section. Managing different build Information and adding Parameters used in job are some of the tasks which can be defined in this section. 

6. Source Code Management: This section provide instruction on how to extract latest code in the workspace,  from git, svn or local system.





Source Code Jenkins
                   










7. Build Trigger : This section define how the job can be triggered, Whether it is dependent on existing job or is scheduled to run on a fixed time and date periodically.














build trigger Jenkins


Build Environment: This section manages the build environment or workspace with option to clean the workflow before build execution or abort/fail a build if it is struck at a step for long period.
build environment Jenkins 


Build - This is the main section where the actual batch files/ shell command or ant targets are invoked. For testing purpose , we can invoke a maven project in this section. Executing a job means executing the commands provided in the build section.

build Jenkins


Post Build Steps - These are post build steps and include activities like archiving artifact or sending a mail with build details or publishing testng/junit test results.

Post build Jenkins