This repository was archived by the owner on Nov 29, 2018. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 194
This repository was archived by the owner on Nov 29, 2018. It is now read-only.
Selenium (javascript) crashes switching to webview window in Chrome apps #7984
Copy link
Copy link
Closed
Description
Originally reported on Google Code with ID 7984
To use Selenium for testing a packaged Chrome app, we need to start the browser with
the Chrome app flag and navigate to the Chrome app window. When the Chrome app window
contains a "webview" (which is a Chrome-specific HTML tag that works only in Chrome
apps), Selenium crashes when enumerating window handles, with the message "UnknownError:
unknown error: DevTools returned unknown type:webview".
To reproduce:
Start Selenium with Chrome driver and option to run an unpacked Chrome app. The app
must be a "packaged Chrome app", that is, it will open a separate window when started.
The packaged chrome app must use a "webview".
Here is some coffeescript code to start the chrome driver with an option to load a
packaged chrome app.
chrome = require 'selenium-webdriver/chrome'
capabilities = webdriver.Capabilities.chrome()
chromeOptions = new chrome.Options()
chromeOptions.addArguments "--load-and-launch-app=./chrome_app"
driver = new webdriver.Builder()
.withCapabilities(capabilities)
.setChromeOptions(chromeOptions)
.build()
When this is started, Chrome browser opens with two windows: an empty browser window
and a Chrome app window.
The "webview" element in the Chrome app window will take a while to load its content.
Until that happens, Selenium can enumerate the open windows without any problem. We
can wait until the number of open windows reaches 3.
printWindows = ->
driver.getAllWindowHandles().then (handles) ->
console.log "got #{handles.length} windows"
printWindows()
Initially the number of open windows is 1, then it becomes 2, and when the "webview"
element finished loading its content, the number of open windows cannot be determined
because of this crash. Selenium also can't switch to the chrome app window anymore
(the window handle was fetched previously and stored).
UnknownError: unknown error: DevTools returned unknown type:webview
(Session info: chrome=37.0.2062.124)
(Driver info: chromedriver=2.10.267517,platform=Mac OS X 10.9.4 x86_64)
==== async task ====
WebDriver.switchTo().window(CDwindow-015FE96F-3231-EA8E-01EF-E2B3B5AA09B5)
It would be not easy to give a self-contained code example here, because it involves
making a complete Chrome app and a javascript test suite. I
Selenium version: selenium-webdriver 2.42.1 (javascript), Chromedriver 2.10, Selenium
2.43.0
OS: Mac OSX
Browser: Chrome
Browser version: 37
Reported by sergei@versal.com on 2014-10-01 22:46:51