Launching Chrome Driver, but not able to do any actions?

荒凉一梦 提交于 2019-12-12 03:38:32

问题


I am trying to run my webdriver tests in Chrome. Here are the steps I'm using to launch Chrome driver:

Set the chrome binary path

System.setProperty("webdriver.chrome.driver", "paht\\chromedriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized"));
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("AcceptUntrustedCertificates", true);
capabilities.setCapability("AssumeUntrustedCertificateIssuer", true);
capabilities.setCapability("chrome.switches", Arrays.asList("--ignore-certificate-errors"));
driver = new ChromeDriver( capabilities);

My Chrome browser is launched, but its not running any tests, like open url etc? Can some please assist me with the steps needed to launch working chromium browser


回答1:


You aren't going anywhere. You are literally just opening the browser and that's it.

Read the GettingStarted page here:

http://code.google.com/p/selenium/wiki/GettingStarted

Essentially, you are looking for something like:

driver.get("http://www.google.com");



回答2:


you have to download updated Chromedriver from this link

    File file = new File("E://chromedriver.exe"); // set driver path 
    System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
    WebDriver driver = new InternetExplorerDriver();
    driver.get("http://google.com");

&

  public class chrome 
 {

 public static void main(String[] args) {

   System.setProperty("webdriver.ie.driver", "E://chromedriver.exe"); //path of chrome driver
   WebDriver driver = new InternetExplorerDriver();
   driver.get("http://www.google.com");

   }

  }

Check this code, it work for me.



来源:https://stackoverflow.com/questions/13533009/launching-chrome-driver-but-not-able-to-do-any-actions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!