Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用Selenium打开Chrome驱动程序_Selenium - Fatal编程技术网

无法使用Selenium打开Chrome驱动程序

无法使用Selenium打开Chrome驱动程序,selenium,Selenium,当我试图用下面的代码打开Chrome驱动程序时,我遇到了以下异常 chrome窗口会自动打开和关闭。 我的Chrome版本是:12.0.712.0和Chrome驱动程序版本26.0.1383.0 我使用的代码是: System.setProperty("webdriver.chrome.driver","F:\\chromedriver.exe"); ChromeDriver cd = new ChromeDriver(); cd.get("http://www.gmail.com");

当我试图用下面的代码打开Chrome驱动程序时,我遇到了以下异常

chrome窗口会自动打开和关闭。 我的Chrome版本是:12.0.712.0和Chrome驱动程序版本26.0.1383.0

我使用的代码是:

System.setProperty("webdriver.chrome.driver","F:\\chromedriver.exe");
ChromeDriver cd = new ChromeDriver();
cd.get("http://www.gmail.com");



tarted ChromeDriver
port=10298
version=26.0.1383.0
log=F:\Selnium\Module11\chromedriver.log
Exception in thread "main" org.openqa.selenium.WebDriverException: 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,  (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.65 seconds
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: 'ANKUR-PC', ip: '169.254.81.96', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_40'
Driver info: org.openqa.selenium.chrome.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:193)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
    at org.openqa.selenium.chrome.ChromeDriver.startSession(ChromeDriver.java:182)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(`enter code here`RemoteWebDriver.java:115)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:161)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:150)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107)
    at Selenium.main(Selenium.java:39)
使用-

1 | Chrome 25+版本

2 |最新的铬合金驱动程序


我也面临同样的问题。我刚刚用最新的google chrome驱动程序替换了现有的chrome驱动程序。它工作得很好

我对Fire Fox和chrome?也有同样的问题?。使用HtmlUnitDriver,它是通用的。不需要FireFox或任何其他浏览器

import org.openqa.selenium.htmlunit.HtmlUnitDriver;
htmldriver = new HtmlUnitDriver();
public class DemoTest {
WebDriver htmldriver;
public void setup() {
htmldriver.get("http://www.seleniumframework.com/demo-sites/");
}
}

更新您的浏览器版本Prashnath感谢您的回复。你知道我应该更新到哪个Chrome版本吗?Chrome 25+版本;使用最新的Chrome驱动程序。普拉什纳特。最新版本的Chrome和Chrome驱动程序无法解决此问题。将你的答案标记为有用。谢谢,让我贴上同样的答案:
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
htmldriver = new HtmlUnitDriver();
public class DemoTest {
WebDriver htmldriver;
public void setup() {
htmldriver.get("http://www.seleniumframework.com/demo-sites/");
}
}