0
votes

I am pretty new to Selenium world. I have been stuck with this code of opening a basic facebook page and it keeps throwing an error saying:

Starting ChromeDriver 78.0.3904.105 (60e2d8774a8151efa6a00b1f358371b1e0e07ee2-refs/branch-heads/3904@{#877}) on port 8852 Only local connections are allowed. Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code. Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48' System info: host: 'ATLMD2226268', ip: '10.7.0.108', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_211'

Code I am using is:

package NewPackage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class MyClass {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\vaaggarw\\Downloads\\chromedriver_win32\\chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        options.setBinary("C:\\Program Files (x86)\\Google Chrome (Local)\\chrome.exe");
        WebDriver driver = new ChromeDriver();
        String baseUrl = "http://www.facebook.com";
        String tagName = "";

        driver.get(baseUrl);
        tagName = driver.findElement(By.id("email")).getTagName();
        System.out.println(tagName);
        driver.close();
        System.exit(0);
}
}
1
Do you have Chrome browser installed on the system?sen4ik
You are not using the options... do this: WebDriver driver = new ChromeDriver(options);pcalkins

1 Answers

0
votes
  1. make sure all selenium jars are not missing in your project. If not delete them anyway and add new jars from fresh download
  2. clean your project
  3. as pcalkins advises, use the chrome options propertly