Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

chrome driver with selenium

View previous topic View next topic Go down

chrome driver with selenium

Post by sreekumar on 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());
}
}

sreekumar
Active particpant
Active particpant

Posts : 16
Join date : 2011-12-27
Age : 31
Location : Hyderabad

Back to top Go down

Re: chrome driver with selenium

Post by qappbc on 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();

}

-----------------------------------------------

qappbc
Amateur
Amateur

Posts : 38
Join date : 2011-10-13

Back to top Go down

Re: chrome driver with selenium

Post by sreekumar on 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)

sreekumar
Active particpant
Active particpant

Posts : 16
Join date : 2011-12-27
Age : 31
Location : Hyderabad

Back to top Go down

Re: chrome driver with selenium

Post by qappbc on 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.

qappbc
Amateur
Amateur

Posts : 38
Join date : 2011-10-13

Back to top Go down

Re: chrome driver with selenium

Post by sreekumar on 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]

sreekumar
Active particpant
Active particpant

Posts : 16
Join date : 2011-12-27
Age : 31
Location : Hyderabad

Back to top Go down

Re: chrome driver with selenium

Post by sreekumar on 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 ...

sreekumar
Active particpant
Active particpant

Posts : 16
Join date : 2011-12-27
Age : 31
Location : Hyderabad

Back to top Go down

Re: chrome driver with selenium

Post by qappbc on 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

qappbc
Amateur
Amateur

Posts : 38
Join date : 2011-10-13

Back to top Go down

Re: chrome driver with selenium

Post by qappbc on 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

qappbc
Amateur
Amateur

Posts : 38
Join date : 2011-10-13

Back to top Go down

Re: chrome driver with selenium

Post by sreekumar on Wed Jan 11, 2012 10:51 am

i am also using Chrome version 12.0.712.0.

sreekumar
Active particpant
Active particpant

Posts : 16
Join date : 2011-12-27
Age : 31
Location : Hyderabad

Back to top Go down

Re: chrome driver with selenium

Post by ankur_infy on 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

ankur_infy

Posts : 3
Join date : 2012-05-15

Back to top Go down

Re: chrome driver with selenium

Post by ashish_techie on 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


ashish_techie
Amateur
Amateur

Posts : 73
Join date : 2011-08-09

Back to top Go down

Re: chrome driver with selenium

Post by Sponsored content Today at 7:15 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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