In this article we are going to see necessary steps for running selenium web driver code in Google Chrome. I am using c# code with VS2010.
Step 1 : Install Google Chrome in your PC from this link
Step 2 : Install Google Chrome Driver from this link
Step 3 : After adding dll in properties of the project , we have to add the references in the class.
using OpenQA.Selenium.Chrome;[For basic idea on how to set up selenium environment, see the post]
Step 4:
Then we have to initiate the driver object as Google Chrome Driver.
private IWebDriver driver = new ChromeDriver();
Now this driver can be used Just Like as other Firefox or IE drivers.
We can initiate Chrome Driver in 6 ways(overridden).
1.With no parameter
-ChromeDriver();
2.With a path [need when running remotely]
-ChromeDriver("stringPath")
3. With an Option
-ChromeDriver(options)
4. With a path and an Option
-ChromeDriver("stringPath", options)
5. With a path, an option and Timeout(The maximum amount of time to wait for each command.)
-ChromeDriver("stringPath",options, cmdTout)
6. With an option, timeout and a specific driver Service.
- ChromeDriver(service, options,cmdTout)
Note : In every case ,
-"stringPath" is the path to the directory containing ChromeDriver.exe. Ex "C:\Users\ssarker\Downloads"
- option is an object of OpenQA.Selenium.Chrome.ChromeOptions
- cmdTout is an object of System.TimeSpan
- service is an object of OpenQA.Selenium.DriverService
Chrome driver will be found in this link. Install windows edition. You can get more detail here.
Note :
It is better to use with string. I use following code for initiating chrome driver(with chrome driver location).
public IWebDriver driver = new ChromeDriver(@"C:\") ;
This string can be other remotely located PC accessible over LAN.
There might be error for version on chrome console(i found, expected version is less then found version). To avoid the error, download latest web driver and chrome.
I will continuously update note section incrementally(after I find and solve problems regarding running in Chrome)
...Thanks...:)...
Step 1 : Install Google Chrome in your PC from this link
Step 2 : Install Google Chrome Driver from this link
Step 3 : After adding dll in properties of the project , we have to add the references in the class.
using OpenQA.Selenium.Chrome;[For basic idea on how to set up selenium environment, see the post]
Step 4:
Then we have to initiate the driver object as Google Chrome Driver.
private IWebDriver driver = new ChromeDriver();
Now this driver can be used Just Like as other Firefox or IE drivers.
We can initiate Chrome Driver in 6 ways(overridden).
1.With no parameter
-ChromeDriver();
2.With a path [need when running remotely]
-ChromeDriver("stringPath")
3. With an Option
-ChromeDriver(options)
4. With a path and an Option
-ChromeDriver("stringPath", options)
5. With a path, an option and Timeout(The maximum amount of time to wait for each command.)
-ChromeDriver("stringPath",options, cmdTout)
6. With an option, timeout and a specific driver Service.
- ChromeDriver(service, options,cmdTout)
Note : In every case ,
-"stringPath" is the path to the directory containing ChromeDriver.exe. Ex "C:\Users\ssarker\Downloads"
- option is an object of OpenQA.Selenium.Chrome.ChromeOptions
- cmdTout is an object of System.TimeSpan
- service is an object of OpenQA.Selenium.DriverService
Chrome driver will be found in this link. Install windows edition. You can get more detail here.
Note :
It is better to use with string. I use following code for initiating chrome driver(with chrome driver location).
public IWebDriver driver = new ChromeDriver(@"C:\") ;
This string can be other remotely located PC accessible over LAN.
There might be error for version on chrome console(i found, expected version is less then found version). To avoid the error, download latest web driver and chrome.
I will continuously update note section incrementally(after I find and solve problems regarding running in Chrome)
...Thanks...:)...