Selenium Chromedriver causes Chrome to start without configured plugins, bookmarks and other settings

StackOverflow https://stackoverflow.com/questions/10425799

  •  05-06-2021
  •  | 
  •  

Frage

I am a new user of Selenium. I want to use it to start up the Chrome browser but I have a problem.

public static void processor(String url, String name) {     
    System.setProperty("webdriver.chrome.driver", "C:/Documents and Settings/jingxiong/Local Settings/Application Data/Google/Chrome/Application/chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    driver.get(url);
    WebElement element = driver.findElement(By.name(name));
    element.sendKeys("google");
    element.submit();
    System.out.println("Page title is: " + driver.getTitle());
    driver.quit();
} 

When I run this example the Chrome browser starts ok but without configured plugins, my settings or bookmarks. What should I do to cause it load these? Thank you.

War es hilfreich?

Lösung

You should first read chromedriver document in selenium wiki. Its available here - http://code.google.com/p/selenium/wiki/ChromeDriver

As mentioned in the wiki:- Similarly, to load an extension when Chrome starts:

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
  capabilities.setCapability("chrome.switches", Arrays.asList("--load-extension=/path/to/extension/directory"));
  WebDriver driver = new ChromeDriver(capabilities);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top