3

i am able to launch the Chrome browser empty window with the help of below/above code but their is some error i am getting

[3676:2080:0621/180047:ERROR:cache_util_win.cc(20)] Unable to move the cache: 0
[3676:2080:0621/180047:ERROR:cache_util.cc(134)] Unable to move cache folder C:\Users\Dhillon's\AppData\Local\Google\Chrome\User Data\ShaderCache\GPUCache to C:\Users\Dhillon's\AppData\Local\Google\Chrome\User Data\ShaderCache\old_GPUCache_000
[3676:2080:0621/180047:ERROR:cache_creator.cc(129)] Unable to create cache
[3676:2080:0621/180047:ERROR:shader_disk_cache.cc(589)] Shader Cache Creation failed: -2

if i use the driver.get(); command its also not working

The code i am using is:

package LearnStart;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class SeleniumStart {

    public static void main(String[] args) throws InterruptedException {
        // TODO Auto-generated method stub
        System.setProperty("webdriver.chrome.driver",
                "C:\\Program Files         (x86)\\Google\\Chrome\\Application\\chrome.exe");
        WebDriver driver = new ChromeDriver();
        // driver.close();
        // driver.get("http://www.google.com");
    }

}
Sanjeev
  • 9,876
  • 2
  • 22
  • 33
balvinder dhillon
  • 109
  • 1
  • 2
  • 10
  • 1
    you can refer this post for your issue [http://stackoverflow.com/questions/13724778/how-to-run-selenium-webdriver-test-cases-in-chrome](http://stackoverflow.com/questions/13724778/how-to-run-selenium-webdriver-test-cases-in-chrome) – Ravikar Bhardwaj Jun 21 '16 at 12:42

2 Answers2

3

In this line:

System.setProperty("webdriver.chrome.driver","C:\\Program Files         (x86)\\Google\\Chrome\\Application\\chrome.exe");

You're setting the chrome browser binary path, what you should set here is the chromedriver path.

Mobrockers
  • 2,128
  • 1
  • 16
  • 28
  • So you are saying we can not use the installed chrome browser – balvinder dhillon Jun 21 '16 at 12:40
  • BTW it worked now but i dont know why it is not working with that path !! thank You – balvinder dhillon Jun 21 '16 at 12:43
  • 3
    Selenium needs a driver to talk to the browser. The driver for chrome is chromedriver, and needs to be downloaded. Then you need to tell selenium where the chromedriver is located in your filepath. Chromedriver will automatically find your chrome install location for you, and it **will** use your chrome install. But the driver is what can talk to chrome, your browser cannot. – Mobrockers Jun 21 '16 at 12:43
2

It mistake was, if you try launch new copy of browser while main copy of browser work. Both of them are trying use same cache. Way to avoid this - just copy your User Data, and attach it to your Selenium code.

Sorry, i can provide only JS code:

    var webdriver = require('selenium-webdriver');
    var chrome = require('selenium-webdriver/chrome');
    var o = new chrome.Options();
    o.addArguments("user-data-dir=c:/Users/User/AppData/Local/Google/Chrome/User Data/");   

//(*)string that is above, connects your Chrome profile to Selenium

    var driver = new webdriver.Builder()
        .forBrowser('chrome')
        .setChromeOptions(o).build(); 

Copy User Data folder, and give path of your copy to Selenium

o.addArguments("user-data-dir=c:/Users/User/AppData/Local/Google/Chrome/User Data Copy/");  

Your can find User Data folder along this path:

C:/Users/User/AppData/Local/Google/Chrome/User Data