是否已弃用ChromeDriverfunction?

我有一段代码完美无缺,直到今天。

public class TestSelenium { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver","chromedriver\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("https://google.com"); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.name("q")).sendKeys("hello world"); } } 

上面的简单代码输出以下错误:

  Started ChromeDriver port=25456 version=26.0.1383.0 log=C:\Use................omedriver.log Exception in thread "main" org.openqa.selenium.WebDriverException: Unknown command 'WaitForAllTabsToStopLoading'. Options: AcceptOrDismissAppModalDialog, ActionOnSSLBlockingPage, ActivateTab, AddBookmark, AddDomEventObserver, AppendTab, ApplyAccelerator, BringBrowserToFront, ClearEventQueue, CloseBrowserWindow, CloseTab, CreateNewAutomationProvider, DeleteCookie, DeleteCookieInBrowserContext, DoesAutomationObjectExist, DragAndDropFilePaths, ExecuteJavascript, ExecuteJavascriptInRenderView, GetActiveTabIndex, GetAppModalDialogMessage, GetBookmarkBarStatus, GetBookmarksAsJSON, GetBrowserInfo, GetBrowserWindowCount, GetChromeDriverAutomationVersion, GetCookies, GetCookiesInBrowserContext, GetDownloadDirectory, GetExtensionsInfo, GetIndicesFromTab, GetLocalStatePrefsInfo, GetMultiProfileInfo, GetNextEvent, GetPrefsInfo, GetProcessInfo, GetSecurityState, GetTabCount, GetTabIds, GetTabInfo, GetViews, GoBack, GoForward, InstallExtension, IsDownloadShelfVisible, IsFindInPageVisible, IsMenuCommandEnabled, IsPageActionVisible, IsTabIdValid, MaximizeView, NavigateToURL, OpenFindInPage, OpenNewBrowserWindow, OpenNewBrowserWindowWithNewProfile, OpenProfileWindow, OverrideGeoposition, RefreshPolicies, Reload, RemoveBookmark, RemoveEventObserver, ReparentBookmark, RunCommand, SendWebkitKeyEvent, SetBookmarkTitle, SetBookmarkURL, SetCookie, SetCookieInBrowserContext, SetDownloadShelfVisible, SetExtensionStateById, SetLocalStatePrefs, SetPrefs, SetViewBounds, SimulateAsanMemoryBug, TriggerBrowserActionById, TriggerPageActionById, UninstallExtensionById, UpdateExtensionsNow, WaitForBookmarkModelToLoad, WaitUntilNavigationCompletes, WebkitMouseButtonDown, WebkitMouseButtonUp, WebkitMouseClick, WebkitMouseDoubleClick, WebkitMouseDrag, WebkitMouseMove, AcceptCurrentFullscreenOrMouseLockRequest, AddOrEditSearchEngine, AddSavedPassword, CloseNotification, DenyCurrentFullscreenOrMouseLockRequest, DisablePlugin, EnablePlugin, FindInPage, GetAllNotifications, GetDownloadsInfo, GetFPS, GetHistoryInfo, GetInitialLoadTimes, GetNTPInfo, GetNavigationInfo, GetOmniboxInfo, GetPluginsInfo, GetSavedPasswords, GetSearchEngineInfo, GetV8HeapStats, ImportSettings, IsFullscreenBubbleDisplayed, IsFullscreenBubbleDisplayingButtons, IsFullscreenForBrowser, IsFullscreenForTab, IsFullscreenPermissionRequested, IsMouseLockPermissionRequested, IsMouseLocked, KillRendererProcess, LaunchApp, LoadSearchEngineInfo, OmniboxAcceptInput, OmniboxMovePopupSelection, PerformActionOnDownload, PerformActionOnInfobar, PerformActionOnSearchEngine, RemoveNTPMostVisitedThumbnail, RemoveSavedPassword, RestoreAllNTPMostVisitedThumbnails, SaveTabContents, SetAppLaunchType, SetOmniboxText, SetWindowDimensions, WaitForAllDownloadsToComplete, WaitForNotificationCount, (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 52 milliseconds Build info: version: '2.28.0', revision: '18309', time: '2012-12-11 20:21:18' System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_11' Session ID: 987719ad2795cc183f7dba Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{platform=XP, chrome.chromedriverVersion=26.0.1383.0, acceptSslCerts=false, javascriptEnabled=true, browserName=chrome, rotatable=false, locationContextEnabled=false, version=29.0.1547.57, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=true}] 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:525) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:533) at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:276) at genealogy2.TestSelenium.main(TestSelenium.java:21) 

我很困惑…… Fluent wait什么问题? 是否对Selenium进行了任何更改,或者这种错误是否可能是由于Java自动升级造成的? (PS:我没有手动升级Java和Selenium)我是否需要升级ChromeDriver? 我试图搜索最新版本,但找不到我使用的那个更新版本

我还尝试了以下方法:

 public class TestSelenium { public static void main(String[] args) { WebDriver driver = new HtmlUnitDriver(); driver.get("https://google.com"); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.name("q")).sendKeys("hello world"); System.out.println("hi"); } } 

上面的代码工作正常…所以这是否意味着问题是与chrome驱动程序???

我们的回归系统也产生了这个错误。 升级到最新的ChromeDriver,您将被设置。

它发生在所有在后台运行GoogleUpdate的Selenium 2用户身上。 一旦chrome v29问世,它似乎与旧的chromedriver脱节了。 更新到最新的chromedriver,似乎解决了这个问题。

你可以在这里找到二进制文件