【问题标题】:Unable to open Chrome driver using Selenium无法使用 Selenium 打开 Chrome 驱动程序
【发布时间】:2017-01-20 21:29:59
【问题描述】:

当尝试使用以下代码打开 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)

【问题讨论】:

  • 更新您的浏览器版本
  • 普拉什纳特感谢您的回复。你知道我应该更新到哪个 Chrome 版本吗?
  • Chrome 25+ 版本;使用最新的 Chrome 驱动程序。 chromedriver.storage.googleapis.com/index.html?path=2.9
  • 普拉什纳特。它不是用最新版本的 Chrome 和 Chrome 驱动程序解决的。将您的答案标记为有用。谢谢
  • 好的,让我在答案中粘贴相同的内容:)

标签: selenium


【解决方案1】:

使用-

1| Chrome 25+ 版本;

2| 最新的 Chrome 驱动程序

http://chromedriver.storage.googleapis.com/index.html?path=2.9/

【讨论】:

    【解决方案2】:

    我对 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/");
    }
    }
    

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 2020-07-29
        • 2014-04-03
        • 2019-10-28
        • 1970-01-01
        • 2017-05-01
        • 2014-01-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多