Jenkins not executing selenium web driver code with chrome browser whereas its working well if user run through Eclipse
<p>I am using selenium java webdriver version 2.53.0, ChromeDriver 2.22.397933, chrome browser Version 51.0.2704.103. </p>

<p>I have created a maven project for our ACS automation code written in java. I am able to run my java script using eclipse but I am unable to run using Jenkins tool. Earlier I was able to run same script using both (Eclipse IDE and Jenkins) but suddenly, don't know why jenkins is giving the following error.</p>

<p>Can anyone please help me to sort out this problem ?</p>

<p><strong>1st log:</strong></p>

<blockquote>
  <p>Running TestSuite
  Starting ChromeDriver 2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b) on port 13433
  Only local connections are allowed.
  Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 64.775 sec &lt;&lt;&lt; FAILURE! - in TestSuite
  lastConnectionStatus(AcsAutomation.Sanity_TestCase_LastConnectionStatus)  Time elapsed: 64.093 sec  &lt;&lt;&lt; FAILURE!
  org.openqa.selenium.WebDriverException: 
  chrome not reachable
    (Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
  Command duration or timeout: 62.44 seconds
  Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
  System info: host: 'DT0029711', ip: '10.49.64.91', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_79'
  Driver info: org.openqa.selenium.chrome.ChromeDriver </p>
</blockquote>

<p><strong>2nd Log:</strong></p>

<blockquote>
  <p>Starting ChromeDriver 2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b) on port 41567
  Only local connections are allowed.
  Starting ChromeDriver 2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b) on port 36032
  Only local connections are allowed.
  Starting ChromeDriver 2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b) on port 28867
  Only local connections are allowed.
  Starting ChromeDriver 2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b) on port 4502
  Only local connections are allowed.
  Tests run: 9, Failures: 8, Errors: 0, Skipped: 0, Time elapsed: 318.1 sec &lt;&lt;&lt; FAILURE! - in TestSuite
  deviceReboot(AcsAutomation.Sanity_TestCase_DeviceReboot)  Time elapsed: 63.74 sec  &lt;&lt;&lt; FAILURE!
  org.openqa.selenium.WebDriverException: 
  unknown error: unable to discover open pages
    (Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
  Command duration or timeout: 62.39 seconds
  Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
  System info: host: 'DT0029711', ip: '10.49.64.91', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_79'
  Driver info: org.openqa.selenium.chrome.ChromeDriver</p>
</blockquote>

<p>Code :</p>

<pre><code>public class Sanity_TestCase_LastConnectionStatus {

    public static WebDriver driver;
    DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");


    @Test
    public void lastConnectionStatus() throws ParseException, InterruptedException,java.text.ParseException, IOException {

        System.setProperty("webdriver.chrome.driver", "D:\\BrowserDriver\\chromedriver.exe");
        driver = new ChromeDriver();

        DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
        DateFormat LogDateFormat = new SimpleDateFormat("dd-MM-yyyy-hh-mm-ss");
        String Timestamp = LogDateFormat.format(new Date());
        //System.out.println("current timestamp is "+Timestamp);

        String expectedTitle = "Friendly TR69 Suite Management Console : Update a CPE - List";
        String actualTitle = "";
        String actualDeviceSerialNo = "";
        String registrationDate = "";
        String lastConnection = "";

        //Create FileInputStream Object
        File file = new File("C:\\Users\\Nakul.Dhenge\\workspace\\AcsAutomation\\src\\test\\java\\AcsAutomation\\datafile.properties");
        FileInputStream fileInput = null;
        fileInput = new FileInputStream(file);
        //Creates Properties object
        Properties prop = new Properties();
        //load properties file
        prop.load(fileInput);

        System.out.println("\n ****** Test Case Name : Sanity_TestCase_LastConnectionStatus : Checking Last Connection Status of Device with ACS ******\n");
        String baseUrl = prop.getProperty("BASE_URL");
        String expectedDeviceSerialNo = prop.getProperty("SERIAL_NUMBER_1");

        //Maximize the browser window
        driver.manage().window().maximize();
        //launch browser and direct it to the Base URL
        driver.get(baseUrl);
        // Enter User name
        driver.findElement(By.id("txtName")).sendKeys(prop.getProperty("USERNAME")); //FIXME --configurable parameter
        // Enter Password
        driver.findElement(By.id("txtPassword")).sendKeys(prop.getProperty("PASSWORD")); //FIXME --configurable parameter
        // click on Login Button
        System.out.println("Wait for 4 sec to press login button");
        Thread.sleep(4000);
        driver.findElement(By.xpath("//*[@id='btnLogin_btn']")).click();
        // Wait for Page to Load
        System.out.println("wait for 10 sec to load webpage!");
        Thread.sleep(10000);
        // Get the actual value of the title
        actualTitle = driver.getTitle();
        System.out.println("Actaul Title is:" +actualTitle);
        /*
         * compare the actual title of the page with the expected one and print
         * the result as "Passed" or "Failed"
         */
        if (actualTitle.contentEquals(expectedTitle)){
            System.out.println("Expected Title found from Webpage, means web page loads properly");
        } else {
            System.out.println("Title Not Found From Webpage, means webpage not loaded properly but script can run properly"); // This check is not for failing Test case
        }

        System.out.println("wait for 5 sec to click sub-menu");
        Thread.sleep(5000);
        // click on "Search" option from sub-menu
        driver.findElement(By.xpath("//*[@id='SubMenusList']/table/tbody/tr[4]/td")).click();
        System.out.println("wait for 5 sec. to move driver on another web frame");
        Thread.sleep(5000);
        // SWITCH TO FRAME 
        driver.switchTo().frame("frmDesktop");
        // By default "Search match only" checkbox is in checked state, so by clicking it will become unchecked.
        driver.findElement(By.name("rdSearchExactly")).click();
        System.out.println("Wait for 5 sec to load webpage with proper input box to enter Sr.No.!");
        Thread.sleep(5000);
        // Search by is always Default and first Option "Device Serial Number" so search device using Serial No.
        driver.findElement(By.id("tbDeviceID")).sendKeys(prop.getProperty("SERIAL_NUMBER_1")); //FIXME configurable parameter
        driver.findElement(By.id("tbDeviceID")).click();
        driver.findElement(By.id("btnSearch_btn")).click();
        // wait to load device
        System.out.println("wait for 5 sec to load webpage!");
        Thread.sleep(5000);

        actualDeviceSerialNo = driver.findElement(By.xpath(".//*[@id='tblGrid']/tbody/tr/td[2]/table/tbody/tr[8]/td[2]")).getText();
        System.out.println("Serial Number " + actualDeviceSerialNo);
        // Check found device is correct or incorrect and that way passed or fail the Test case
        if (actualDeviceSerialNo.contentEquals(expectedDeviceSerialNo)){
            System.out.println("Actual and Expected Serial No. matched Properly");
        } 
        else 
        {
            System.out.println("There is a mismatch in Serial No.");
            System.out.println("Something went wrong, Please check the configuration file...");
        }

        // It's a neccessory to switch driver from selected frame to default content.
        driver.switchTo().defaultContent();

        /*** Step 3: Check last connection status ***/
        //--------------------------------------------/

        driver.switchTo().frame("frmDesktop");
        registrationDate = driver.findElement(By.xpath(".//*[@id='tblGrid']/tbody/tr/td[2]/table/tbody/tr[9]/td[2]")).getText();
        System.out.println("Registration Date is\t:=&gt; "+registrationDate);

        //Thread.sleep(1000);
        lastConnection = driver.findElement(By.xpath(".//*[@id='tblGrid']/tbody/tr/td[2]/table/tbody/tr[10]/td[2]")).getText();
        System.out.println("Last Connection Status\t:=&gt; "+lastConnection);

        SimpleDateFormat dateFormat1 = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
        Date Date1=dateFormat1.parse(lastConnection);
        dateFormat1=new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
        String Final_lastConnection = dateFormat1.format(Date1);
        System.out.println("Last Connection Status\t:=&gt;"+Final_lastConnection);


        Date date = new Date();
        String currentDate = dateFormat.format(date);
        System.out.println("Current Date and Time is:=&gt;"+currentDate);


        /* Logic To take out time difference between two DateTime *****/

        SimpleDateFormat dateFormat2 = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss");

        Date D1=null;
        Date D2=null;
        try {
            D1 = dateFormat2.parse(Final_lastConnection);
            D2 = dateFormat2.parse(currentDate);

            //in milliseconds
            long diff = D2.getTime() - D1.getTime();
            System.out.println("Time Difference:"+diff);

            long diffSeconds = diff / 1000 % 60;
            long diffMinutes = diff / (60 * 1000) % 60;
            long diffHours = diff / (60 * 60 * 1000) % 24;
            long diffDays = diff / (24 * 60 * 60 * 1000);

            System.out.println(diffDays + " days, ");
            System.out.println(diffHours + " hours, ");
            System.out.println(diffMinutes + " minutes, ");
            System.out.println(diffSeconds + " seconds.");
            if(diffMinutes&lt;10)
            {
                System.out.println("Device Connection State is Latest One");
            }
            else
            {
                System.out.println("Need to run Test case again, may be 'get current' task is pending \n Device is not connected since long time");

            }

        } catch (Exception e) {
            e.printStackTrace();
        }

        driver.switchTo().defaultContent();

        System.out.println("\n ==== Sanity_TestCase_LastConnectionStatus: Test Case Executed Successfully ==== \n");
    }


    /**** Either Test Fail or Pass but Browser will close because of below method ****/

    @AfterMethod
    public void tearDown()
    {
        driver.close();
    }


}
</code></pre>