0

I'm trying to run Selenium WebDriver in Eclipse using Google Chrome but when I run my code I get this error:

Starting ChromeDriver 2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed) on port 40315

Only local connections are allowed.

Here is my code:

package Login; 

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class CorrectLogin {
  private WebDriver driver;
  private String baseUrl;
  private boolean acceptNextAlert = true;
  private StringBuffer verificationErrors = new StringBuffer();

@Before
public void setUp() throws Exception {
  System.setProperty("webdriver.chrome.driver", "D://DownLoads//chromedriver.exe");
  WebDriver driver = new ChromeDriver();   
  baseUrl = "https://10.96.0.65:9443/";
  driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

@Test
public void testFirstTestCase() throws Exception {
  driver.get(baseUrl + "POSAdminTool/AdminTool/Login.faces");
  driver.findElement(By.id("form1:passwordLabel")).clear();
  driver.findElement(By.id("form1:passwordLabel")).sendKeys("1234");
  driver.findElement(By.id("form1:usernameLabel")).clear();
  driver.findElement(By.id("form1:usernameLabel")).sendKeys("superuser");
  driver.findElement(By.id("form1:btn_login")).click();

  assertEquals("Search Account", driver.findElement(By.id("searchTitle")).getText());
}
Nick Vanderhoven
  • 3,018
  • 18
  • 27
Ahmed Selim
  • 99
  • 1
  • 11
  • Possible duplicate of [When run webdriver with chrome browser , getting message " Only local connections are allowed" although broser launches properly](http://stackoverflow.com/questions/25080500/when-run-webdriver-with-chrome-browser-getting-message-only-local-connection) – Nick Vanderhoven Dec 01 '16 at 14:25
  • I tried this solution but it doesn't work – Ahmed Selim Dec 01 '16 at 14:33
  • 1
    It's not an error, it's the first line of logging for Chrome driver. Add the lines afterwards which probably contain the error. It's probably a versioning issue. verify latest chromedriver.exe – Moshisho Dec 01 '16 at 14:44
  • I'm using chromedriver 2.25 latest one with Google chrome 54 – Ahmed Selim Dec 01 '16 at 15:15

1 Answers1

0
  1. Maybe the reason is in the flashes ?

    System.setProperty("webdriver.chrome.driver", "bin/chromedriver.exe");

  2. Check - do you have a file chromedriver.exe in this folder?
  3. driver = new ChromeDriver(); Try it - I guess it is a main reason.
Schroet
  • 365
  • 4
  • 8