Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
sreekumar
Active particpant
Active particpant
Posts : 16
Join date : 2011-12-27
Age : 39
Location : Hyderabad

chrome driver with selenium Empty chrome driver with selenium

Sat Jan 07, 2012 9:34 pm
Hi All



I am not able to run sample program in Chrome browser using 'chrome driver' . I was added all chromerdriver jar files and start chromedriver.exe. 'Started chrome driver' is showing in command prompt and no errors in eclipse IDE. But while ran this program Browser is not up. Can you modify the below program as to lauch chrome browser and need to run the selenium script?



or



Please send any sample selenium program that should run in chrome browser using Webdriver.







import static org.junit.Assert.assertEquals;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

@RunWith(BlockJUnit4ClassRunner.class)}
public class ChromeTest extends TestCase {

private static ChromeDriverService service;
private WebDriver driver;

@BeforeClass
public static void createAndStartService() {
service = new ChromeDriverService.Builder()
.usingChromeDriverExecutable(new File("path/to/my/chromedriver"))
.usingAnyFreePort()
.build();
service.start();
}

@AfterClass
public static void createAndStopService() {
service.stop();
}

@Before
public void createDriver() {
driver = new RemoteWebDriver(service.getUrl(),
DesiredCapabilities.chrome());
}

@After
public void quitDriver() {
driver.quit();
}

@Test
public void testGoogleSearch() {
driver.get("http://www.google.com");
WebElement searchBox = driver.findElement(By.name("q"));
searchBox.sendKeys("webdriver");
searchBox.quit();
assertEquals("webdriver - Google Search", driver.getTitle());
}
}
avatar
qappbc
Amateur
Amateur
Posts : 38
Join date : 2011-10-13

chrome driver with selenium Empty Re: chrome driver with selenium

Mon Jan 09, 2012 2:32 am
Ok, your example posted is from this page
http://code.google.com/p/selenium/wiki/ChromeDriver

I did not try to use ChromeDriver in same manner, but
something I thought was simpler in form. You can see
some other people have issues with this as well:
http://stackoverflow.com/questions/6376925/using-chrome-driver-with-selenium-2

Below works for me
----------------------------------------------
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class Browser_Search_Chrome{
public static void main(String[] args) throws InterruptedException {

//Don't seem to be able to get Chromedriver set up in Environ Path, so...
//Path to down loaded chromedriver. E.g., "C:\\selenium\\chromedriver.exe"
System.setProperty("webdriver.chrome.driver", "C:\\selenium\\chromedriver.exe");

//Pausing here seems to make it work better, so...
Thread.sleep(5000l);

WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
Thread.sleep(2000l);

// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));

// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());

// Enter something to search for, then search
element.sendKeys("qtpselenium", Keys.ENTER);
Thread.sleep(5000l);
System.out.println("Page title is: " + driver.getTitle());
driver.quit();

}

-----------------------------------------------
avatar
sreekumar
Active particpant
Active particpant
Posts : 16
Join date : 2011-12-27
Age : 39
Location : Hyderabad

chrome driver with selenium Empty Re: chrome driver with selenium

Tue Jan 10, 2012 1:54 pm
Hi

i tried with above mentioned code. Server is started, but still i am getting one error is showing.

Below is the exception getting while running application:


Started ChromeDriver
port=45600
version=17.0.963.0
[0110/122158:ERROR:automation_json_requests.cc(62)] JSON request failed: GetChromeDriverAutomationVersion
with error: Unknown command. Options: ActivateTab, CloseTab, DeleteCookie, ExecuteJavascript, GetCookies, GetIndicesFromTab, GetTabIds, GetTabTitle, GetTabURL, GoBack, GoForward, IsTabIdValid, NavigateToURL, Reload, SendWebkitKeyEvent, SetCookie, WaitForAllTabsToStopLoading, WebkitMouseClick, WebkitMouseDrag, WebkitMouseMove, AddHistoryItem, AddOrEditSearchEngine, AddSavedPassword, AwaitSyncCycleCompletion, ClearBrowsingData, CloseNotification, DisablePlugin, DisableSyncForDatatypes, EnablePlugin, EnableSyncForDatatypes, FillAutofillProfile, FindInPage, GetActiveNotifications, GetAutofillProfile, GetBlockedPopupsInfo, GetBrowserInfo, GetDownloadsInfo, GetExtensionsInfo, GetHistoryInfo, GetInitialLoadTimes, GetInstantInfo, GetNTPInfo, GetNTPMenuMode, GetNTPThumbnailMode, GetNavigationInfo, GetOmniboxInfo, GetPluginsInfo, GetPrefsInfo, GetSavedPasswords, GetSearchEngineInfo, GetSyncInfo, GetThemeInfo, GetTranslateInfo, ImportSettings, KillRendererProcess, LoadSearchEngineInfo, MoveNTPMostVisitedThumbnail, OmniboxAcceptInput, OmniboxMovePopupSelection, PerformActionOnDownload, PerformActionOnInfobar, PerformActionOnSearchEngine, RemoveNTPMostVisitedThumbnail, RemoveSavedPassword, RestoreAllNTPMostVisitedThumbnails, SaveTabContents, SelectTranslateOption, SetNTPMenuMode, SetNTPThumbnailMode, SetOmniboxText, SetPrefs, SetWindowDimensions, SignInToSync, UnblockAndLaunchBlockedPopup, UninstallExtensionById, UnpinNTPMostVisitedThumbnail, WaitForAllDownloadsToComplete, WaitForNotificationCount,
Exception in thread "main" org.openqa.selenium.WebDriverException: Internal Chrome error during 'GetChromeDriverAutomationVersion': (Unknown command. Options: ActivateTab, CloseTab, DeleteCookie, ExecuteJavascript, GetCookies, GetIndicesFromTab, GetTabIds, GetTabTitle, GetTabURL, GoBack, GoForward, IsTabIdValid, NavigateToURL, Reload, SendWebkitKeyEvent, SetCookie, WaitForAllTabsToStopLoading, WebkitMouseClick, WebkitMouseDrag, WebkitMouseMove, AddHistoryItem, AddOrEditSearchEngine, AddSavedPassword, AwaitSyncCycleCompletion, ClearBrowsingData, CloseNotification, DisablePlugin, DisableSyncForDatatypes, EnablePlugin, EnableSyncForDatatypes, FillAutofillProfile, FindInPage, GetActiveNotifications, GetAutofillProfile, GetBlockedPopupsInfo, GetBrowserInfo, GetDownloadsInfo, GetExtensionsInfo, GetHistoryInfo, GetInitialLoadTimes, GetInstantInfo, GetNTPInfo, GetNTPMenuMode, GetNTPThumbnailMode, GetNavigationInfo, GetOmniboxInfo, GetPluginsInfo, GetPrefsInfo, GetSavedPasswords, GetSearchEngineInfo, GetSyncInfo, GetThemeInfo, GetTranslateInfo, ImportSettings, KillRendererProcess, LoadSearchEngineInfo, MoveNTPMostVisitedThumbnail, OmniboxAcceptInput, OmniboxMovePopupSelection, PerformActionOnDownload, PerformActionOnInfobar, PerformActionOnSearchEngine, RemoveNTPMostVisitedThumbnail, RemoveSavedPassword, RestoreAllNTPMostVisitedThumbnails, SaveTabContents, SelectTranslateOption, SetNTPMenuMode, SetNTPThumbnailMode, SetOmniboxText, SetPrefs, SetWindowDimensions, SignInToSync, UnblockAndLaunchBlockedPopup, UninstallExtensionById, UnpinNTPMostVisitedThumbnail, WaitForAllDownloadsToComplete, WaitForNotificationCount, ). Request details: ({"command":"GetChromeDriverAutomationVersion"}). Using Chrome binary at: C:\Documents and Settings\u0145442\Local Settings\Application Data\Google\Chrome\Application\chrome.exe, version (12.0.712.0) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.11 seconds
Build info: version: '2.16.1', revision: '15405', time: '2012-01-05 12:23:11'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_27'
Driver info: driver.version: ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:435)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:135)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:94)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:86)
at LoginChrome.main(LoginChrome.java:17)
avatar
qappbc
Amateur
Amateur
Posts : 38
Join date : 2011-10-13

chrome driver with selenium Empty Re: chrome driver with selenium

Tue Jan 10, 2012 2:08 pm
What is all your test code -
especially line 17 of LoginChrome.java?

The error reference to JSON requests has me baffled.
There is nothing in what I gave you to try that should have triggered that.
avatar
sreekumar
Active particpant
Active particpant
Posts : 16
Join date : 2011-12-27
Age : 39
Location : Hyderabad

chrome driver with selenium Empty Re: chrome driver with selenium

Tue Jan 10, 2012 4:51 pm
Please see the exact information below :

Added jar files to the selenium project :

1. selenium-java-2.16.1.jar

2. selenium-java-2.16.1-srcs.jar

3. selenium-server-standalone-2.16.1.jar

My code :
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class LoginChrome{
public static void main(String[] args) throws InterruptedException {

//Don't seem to be able to get Chromedriver set up in Environ Path, so...
//Path to down loaded chromedriver. E.g., "C:\\selenium\\chromedriver.exe"
System.setProperty("webdriver.chrome.driver", "D://sreekumar//Tutorial//Selenium//chromedriver.exe");

//Pausing here seems to make it work better, so...
Thread.sleep(5000l);

WebDriver driver =
new ChromeDriver();
driver.get(
"http://www.google.com");
Thread.sleep(2000l);

// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));

// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());

// Enter something to search for, then search
element.sendKeys("qtpselenium", Keys.ENTER);
Thread.sleep(5000l);
System.
out.println("Page title is: " + driver.getTitle());
driver.quit();

}

}

while running the above code chrome driver is started and showing the below exception. Google chrome browser just opens and close in this case.
[size=9]
[0110/150930:ERROR:automation_json_requests.cc(62)] JSON request failed: GetChromeDriverAutomationVersion
[size=9][size=9]Build info: version: '2.16.1', revision: '15405', time: '2012-01-05 12:23:11'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_27'
Driver info: driver.version: ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(
Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(
ErrorHandler.java:147)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(
ErrorHandler.java:113)
at org.openqa.selenium.remote.RemoteWebDriver.execute(
RemoteWebDriver.java:435)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(
RemoteWebDriver.java:135)
at org.openqa.selenium.remote.RemoteWebDriver.(
RemoteWebDriver.java:94)
at org.openqa.selenium.chrome.ChromeDriver.(
ChromeDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.(
ChromeDriver.java:86)
at LoginChrome.main(
LoginChrome.java:17)
[/size][/size][/size]
avatar
sreekumar
Active particpant
Active particpant
Posts : 16
Join date : 2011-12-27
Age : 39
Location : Hyderabad

chrome driver with selenium Empty Re: chrome driver with selenium

Tue Jan 10, 2012 4:53 pm
Please send your gmail id or contact number i will directly touch with you and explain where i was struck ...
avatar
qappbc
Amateur
Amateur
Posts : 38
Join date : 2011-10-13

chrome driver with selenium Empty Re: chrome driver with selenium

Wed Jan 11, 2012 2:02 am
What version of Google Chrome are you using?
ChromeDriver is only compatible with Chrome version 12.0.712.0 or newer
I'm using 15.x

Also, ChromeDriver recently updated.

I would search for or post your issue here:
http://groups.google.com/group/selenium-developers/topics
avatar
qappbc
Amateur
Amateur
Posts : 38
Join date : 2011-10-13

chrome driver with selenium Empty Re: chrome driver with selenium

Wed Jan 11, 2012 2:06 am
BTW, the only selenium jar I am using for this simple example is

selenium-server-standalone-2.16.1.jar
avatar
sreekumar
Active particpant
Active particpant
Posts : 16
Join date : 2011-12-27
Age : 39
Location : Hyderabad

chrome driver with selenium Empty Re: chrome driver with selenium

Wed Jan 11, 2012 10:51 am
i am also using Chrome version 12.0.712.0.
avatar
ankur_infy
Posts : 3
Join date : 2012-05-15

chrome driver with selenium Empty Re: chrome driver with selenium

Tue May 15, 2012 2:23 pm
Hi even i am getting the same issue as mentioned by you. can u please guide me how you got the solution to this.

thanks:D
avatar
ashish_techie
Amateur
Amateur
Posts : 73
Join date : 2011-08-09

chrome driver with selenium Empty Re: chrome driver with selenium

Sat May 19, 2012 10:01 am
You will have to download chromedriver.exe from selenium google code group.
They have made it specifically for chrome.
After that you will have set the system property and keep the path of that exe in the system property.
It works for me and I have been running all kinds of scenarios using chrome.
Google is behind webdriver and google is behind chrome. They make sure it runs on chrome but you need to download chromedriver.exe from selenium google code group and keep it as a system property.

Regards
Ashish
For selenium training visit:
http://qtpselenium.com/selenium-training

Sponsored content

chrome driver with selenium Empty Re: chrome driver with selenium

Back to top
Permissions in this forum:
You cannot reply to topics in this forum