pytest-dev/pytest-splinter

Support for Chrome appears to be broken

aaugustin opened this issue · 3 comments

Selenium and splinter happily open Chrome on my computer, which suggests I've installed dependencies properly, but pytest-splinter won't start with Chrome. The Chrome window opens and closes immediately, re-opens and re-closes immediately, etc. While the flashing effect is nice, it isn't particularly useful ;-)

I found out that I keep hitting the except (IOError, HTTPException, WebDriverException): code path in prepare_browser which closes the browser and restarts it.

Here's a stack trace of how I end up there.

WebDriverException                        Traceback (most recent call last)
/Users/myk/.virtualenvs/amalfi/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py in set_window_size(self, width, height, windowHandle)
    844             'width': int(width),
    845             'height': int(height),
--> 846             'windowHandle': windowHandle})
    847 
    848     def get_window_size(self, windowHandle='current'):

/Users/myk/.virtualenvs/amalfi/lib/python3.5/site-packages/pytest_splinter/webdriver_patches.py in execute(self, driver_command, params)
     54 
     55     def execute(self, driver_command, params=None):
---> 56         result = self._base_execute(driver_command, params)
     57         speed = self.get_speed()
     58         if speed > 0:

/Users/myk/.virtualenvs/amalfi/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
    234         response = self.command_executor.execute(driver_command, params)
    235         if response:
--> 236             self.error_handler.check_response(response)
    237             response['value'] = self._unwrap_value(
    238                 response.get('value', None))

/Users/myk/.virtualenvs/amalfi/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response)
    190         elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
    191             raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
--> 192         raise exception_class(message, screen, stacktrace)
    193 
    194     def _value_or_default(self, obj, key, default):

WebDriverException: Message: unknown error: No current window
JavaScript stack:
Error: No current window
    at checkForExtensionError (chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:14:17)
    at null.callback (chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:67:5)
    at safeCallbackApply (extensions::sendRequest:21:15)
    at handleResponse (extensions::sendRequest:74:7)
  (Session info: chrome=52.0.2743.116)
  (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.6 x86_64)

Here's my current workaround:

@pytest.fixture(scope='session')
def splinter_window_size(splinter_webdriver, splinter_window_size):
    """
    Prevent pytest-splinter from crashing with Chrome.

    """
    if splinter_webdriver == 'chrome':
        return None

    return splinter_window_size

I'm not too sure what info you need to reproduce. I'm running the latest versions of everything on macOS.

Actually this appears to be a duplicate of #71.

Same issue for me. Thanks for the workaround.

I believe it might actually be Splinter issue. This code below does not use pytest-splinter at all and will crash at set_window_size()

import time
from splinter import Browser

executable_path = {'executable_path':'/path/to/chromedriver'}
browser = Browser('chrome', **executable_path)

browser.visit('http://www.google.com');
browser.driver.set_window_size(1366, 768)
time.sleep(5)
browser.quit()
pelme commented

Thanks for the report and great debugging. #71 appears to be the same issue, let's continue the discussion there. :)