java - ChromeDriver 功能是否已被弃用?

标签 java selenium selenium-chromedriver

我有一段代码直到今天都运行得很好。

  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,似乎可以解决该问题。

您可以找到二进制文件 here

关于java - ChromeDriver 功能是否已被弃用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18436156/

相关文章:

python - 如何使用 webDriver(python)最大化 chrome 中的窗口

java - 多线程 http 服务器从客户端浏览器获取 GET 和 POST

javascript - 如何克服 Selenium CSS parent only CSS 选择器限制

javascript - Selenium : How to send variable character strings through executeScript()

java - Selenium Proxy 与 Google Chrome 可移植

javascript - Python/Selenium 在执行 Javascript 时不会切换 Chrome 78 的页面

java - 将 Bitmap 转换为 ByteArray,反之亦然

java - 在 App Engine servlet 中存储已用 token 列表 - java

java - 可调用 : why can we "change" the exception on implementation?

java - 如何查找多个标签的动态 xpath 以及 div 内的文本