You can read my THIS POST to know how to run selenium webdriver test of software application in Mozilla Firefox browser. As you know, webdriver software testing tool support Google Chrome browser too. You need to do something extra for launching webdriver test in in Google chrome browser. Let me describe you steps to launch webdriver test in Google Chrome for software web application.
Create selenium webdriver data driven framework from scratch @This Page.
Download ChromeDriver server
First of all, download latest version of ChromeDriver server for webdriver software testing tool. You can download it directly from https://sites.google.com/a/chromium.org/chromedriver/downloads. Current latest version for win32 is "ChromeDriver 2.15" as shown bellow.
Click on "ChromeDriver 2.15" link. It will take you to download page.
Now in eclipse, create new project with name = 'chromeproject' and create new class with name = 'chromebrowser'. Don't forget to select 'public static void main(String[] args)' method during new java class creation. Write code as shown bellow in class file.
Don't know how to find and evaluate XPath in chrome?
Don't know how to find and evaluate XPath in chrome?
package mytestpack;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class chromebrowser {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.google.com");
if (driver.findElement(By.xpath("//input[@name='q']")).isEnabled()) {
System.out.println("Google search text box Is enabled.");
driver.findElement(By.xpath("//input[@name='q']")).sendKeys("WebDriver Test successful.");
driver.findElement(By.xpath("//button[@name='btnG']")).click();
System.out.println("Google search completed.");
} else {
System.out.println("Google search test box Is Not enabled.");
}
driver.close();
}
}
So now, your software web application's test will run in Google chrome browser. Learn how to execute webdriver test in Internet Explorer browser in THIS POST.
Is ChromeDriver not available for win64???
ReplyDeletehttp://chromedriver.storage.googleapis.com/index.html?path=2.3/
DeleteVery clear & understandable
ReplyDeleteAwesome post
ReplyDeleteVery Nice post
ReplyDeleteWhat path we set in linux 32 bit system. My OS is Ubuntu 12.04 LTS
directly we set home path or any other.
Hi Pls send me code of above example
ReplyDeletenice touturial
ReplyDeletenice..!
ReplyDeleteNice tutorial.!
ReplyDeleteask for code
ReplyDeletegood
ReplyDeletei'm getting error as "The method SetProperty(String, String) is undefined for the type System" also my sytem is win64.
ReplyDeletegood effort. Can I get code please?
ReplyDeletePlease fill this form
Deletehttp://software-testing-tutorials-automation.blogspot.com/p/request-free.html
Excellent work!
ReplyDeleteExcellent work!
ReplyDeleteNice Work...
ReplyDeleteThis comment has been removed by the author.
ReplyDeletegrt work
ReplyDeleteIt is an effective tutorials for beginners. Thanks a lot
ReplyDeletevery very helpful post.. good luck for your good work
ReplyDeleteThanks for this very helpful post.
ReplyDeleteI'm very new to Java...I've a que. regarding the 'import' line..what is it about? Why didn't have to download FireFoxDriver Server just like that for ChromeDriver?
Thanks
You not need driver server file for firefox. You need It for other browsers ike chrome, IE, etc..
DeleteThe link as provided for Chrome driver download doesnt have the file at present, can this be updated to http://chromedriver.storage.googleapis.com/index.html?path=2.14/
ReplyDeleteHi,
ReplyDeleteI am facing one problem here, as I run the above test i can see the below error. Can you help me in running the test without fail.
error details
Starting ChromeDriver (v2.3) on port 18396
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: unable to discover open pages
(Driver info: chromedriver=2.3,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 22.33 seconds
Build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35'
System info: host: 'sys', ip: '14.99.186.14', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_71'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:139)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:171)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:160)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:117)
at chromeProject.Chromebrowser.main(Chromebrowser.java:12)
hi am facing this error ,plz help me
ReplyDeleteException in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function
at test_project.test_class.main(test_class.java:13)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
How did you resolve this error? I am facing same issue.
DeleteCheck your JDk version ,,Update with Recent JDK version,It may work
Deletethanks a lot very effective for beginnners................
ReplyDeletedriver.findElement(By.xpath("//input[@name='q']")).sendKeys("WebDriver Test successful.");
ReplyDeletethis code of line shows the below error please help me.
The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)
driver.findElement(By.id("type_field_name_here")).sendKeys("Web Driver Test Succesful");
Deletet has a simple solution. Change your compiler compliance level from 1.4 to 1.7.
DeleteFollow these steps in your eclipse:
Right click on your java project and select Build Path -> Click on
Configure Build Path...
In project properties window, Click/select Java Compiler at the left
panel
At the right panel, change the Compiler compliance level from 1.4 to 1.7
(Select which is higher version in your eclipse)
Lastly Click on Apply and OK
Now check your code. it will never show the same error.
In above code I facing problem in "sendkeys" it showing The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String).
ReplyDeleteI can't understand whats d meaning of this. Please reply !!!
Even I had faced such issue with SendKeys.After updating to the latest version of the WebDriver, issue got resolved. We need to have latest version of Browser and WebDriver as well..
ReplyDeleteIs ChromeDriver not available for win64 ???
ReplyDeleteI have Got following error message - Can u Please Help
ReplyDeleteStarting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 6290
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.02 seconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: 'narendragawas', ip: '192.168.1.97', os.name: 'Windows 8.1', os.arch: 'x86', os.version: '6.3', java.version: '1.8.0_73'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Hi I got the following error what should i do tell me.. please
ReplyDeleteException in thread "main" java.lang.IllegalStateException: The driver executable does not exist: D:\chromedriver_win32\chromedriver.exe
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:121)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:116)
at org.openqa.selenium.chrome.ChromeDriverService.access$0(ChromeDriverService.java:1)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:116)
at tiyotesting.Citydropdownlist.main(Citydropdownlist.java:16)
Hi I got the following error while run the script please help me.....
ReplyDeleteException in thread "main" java.lang.IllegalStateException: The driver executable does not exist: D:\chromedriver_win32\chromedriver.exe
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:121)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:116)
at org.openqa.selenium.chrome.ChromeDriverService.access$0(ChromeDriverService.java:1)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:116)
at tiyotesting.Citydropdownlist.main(Citydropdownlist.java:16)
I am getting the following error. Can someone please help me on how to proceed?
ReplyDeleteException in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function
at chromebrowser.main(chromebrowser.java:10)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more