ericmckean / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

Selenium (javascript) fails when switching to webview window in Chrome apps #916

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

Original issue reported on code.google.com by ser...@versal.com on 1 Oct 2014 at 11:14

GoogleCodeExporter commented 9 years ago
I could prepare a package with a complete example of a chrome app and selenium 
test code that crashes, but it would take some time. Please let me know if this 
is necessary, - maybe you already know where the problem is.

Original comment by ser...@versal.com on 2 Oct 2014 at 5:25

GoogleCodeExporter commented 9 years ago
Hi Sergei, thanks for the bug report. I'm able to verify this using a sample 
app so you don't need to provide your own example. I've fixed the error here:

https://codereview.chromium.org/655373002/

I'm currently working on making sure we can interact with <webview> elements; 
this will come in a separate commit.

Original comment by samu...@chromium.org on 16 Oct 2014 at 12:07

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 16 Oct 2014 at 12:07

GoogleCodeExporter commented 9 years ago
This change should fix a few other potential crashes - 
https://codereview.chromium.org/654713004/. Will be released with 2.12.

Original comment by samu...@chromium.org on 24 Oct 2014 at 5:54

GoogleCodeExporter commented 9 years ago
The summary of this issue is not clear enough, compared to the actual problem 
in ChromeDriver or Selenium (not a real crash). You may change the summary 
before triggering the release.

Original comment by st...@chromium.org on 24 Oct 2014 at 5:29

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 24 Oct 2014 at 6:25

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 27 Oct 2014 at 8:47

GoogleCodeExporter commented 9 years ago
Used v2.12 and ChromeDriver does not crash when WebView windows are open. 
However, i see that there will be a separate commit for accessing webview 
elements? Is there an ETA or tracking bug for this?

Original comment by vidhes...@gmail.com on 28 Oct 2014 at 12:11

GoogleCodeExporter commented 9 years ago
videsh52: this bug was just for tracking the error that was being thrown to 
selenium, and I'm happy to hear that this doesn't fail for you in 2.12. There's 
no ETA or tracking bug for interaction with <webview> elements right now, but 
feel free to create one if this would be useful for you.

Original comment by samu...@chromium.org on 28 Oct 2014 at 6:36

GoogleCodeExporter commented 9 years ago
Confirm that ChromeDriver 2.12 works now with webview elements in chrome app. 
Thank you! Looking forward to interaction with webview elements in a future 
version of ChromeDriver.

Original comment by ser...@versal.com on 28 Oct 2014 at 6:38

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:25