seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
5k stars 944 forks source link

Browser window not closing for 'test_timeout_failure' example #475

Closed dineshKumar777 closed 4 years ago

dineshKumar777 commented 4 years ago

Thanks for this awesome test framework. When checking out, noticed while running 'test_timeout_failure' example from timeout_test.py file, browser window is not closing after timeout. Usually driver has to quit even on exceptions or timeout, right? or is this an intentional behavior!

mdmintz commented 4 years ago

Hi @dineshKumar777 Which version of SeleniumBase are you using? I'm trying to reproduce that issue on the latest version, but so far I haven't been able to. Can you tell me a bit more about your environment? (Mac, Windows, Linux)? And if you roll back to an earlier version, does the issue stop occurring? And does the issue occur when you run other tests? Thanks.

mdmintz commented 4 years ago

Also paste the run command that you were using when the issue occurred.

mdmintz commented 4 years ago

I think I reproduced it with Firefox. I’ll track it down and put in a fix sometime in the next 12 hours with a new release.

mdmintz commented 4 years ago

@dineshKumar777 Which browser are you using? This might be an issue with Firefox and pytest-timeout, whereby the interrupt during the timeout is a problem for Firefox, but not for Chrome.

mdmintz commented 4 years ago

After some investigation, it’s a bug with pytest-timeout, as when the the timeout is called, it might not be in a safe place in the code, and it may skip tearDown steps where the browser window gets closed. To fix, I’ll create my own version and ship it with SeleniumBase.

dineshKumar777 commented 4 years ago

@mdmintz Glad, you found out root cause of the issue. Sorry couldn't able to reply to your queries on time. (Its midnight for me) Please let me know if there are any more information needed for this issue.

@dineshKumar777 Which browser are you using? This might be an issue with Firefox and pytest-timeout, whereby the interrupt during the timeout is a problem for Firefox, but not for Chrome.

For me issue is reproducible in both chrome and firefox. Following are the details which you asked for.

seleniumbase - 1.34.14
Chrome - 76.0.3809.100
firefox - 72.0.1 (64-bit)

Run command - pytest timeout_test.py 
for firefox - pytest timeout_test.py browser=firefox

LOG:

C:\Users\vdinesh\PycharmProjects\SeleniumBase\examples>pytest timeout_test.py
=========================================================================================================================== test session starts ===========================================================================================================================
platform win32 -- Python 3.7.3, pytest-5.3.2, py-1.8.1, pluggy-0.13.1
rootdir: C:\Users\vdinesh\PycharmProjects\SeleniumBase, inifile: pytest.ini
plugins: cov-2.8.1, forked-1.1.3, html-2.0.1, metadata-1.8.0, ordering-0.6, rerunfailures-8.0, timeout-1.3.4, xdist-1.31.0, seleniumbase-1.34.10
collected 1 item                                                                                                                                                                                                                                                           

timeout_test.py
DevTools listening on ws://127.0.0.1:50579/devtools/browser/937ba528-9c28-4f2d-a6cd-e843e8c510e2

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Stack of MainThread (25876) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\Scripts\pytest-script.py", line 11, in <module>
    load_entry_point('pytest', 'console_scripts', 'pytest')()
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\_pytest\config\__init__.py", line 92, in main
    config=config
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\_pytest\main.py", line 239, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\_pytest\main.py", line 196, in wrap_session
    session.exitstatus = doit(config, session) or 0
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\_pytest\main.py", line 246, in _main
    config.hook.pytest_runtestloop(session=session)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\_pytest\main.py", line 270, in pytest_runtestloop
    item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\_pytest\runner.py", line 81, in pytest_runtest_protocol
    runtestprotocol(item, nextitem=nextitem)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\_pytest\runner.py", line 96, in runtestprotocol
    reports.append(call_and_report(item, "call", log))
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\_pytest\runner.py", line 182, in call_and_report
    call = call_runtest_hook(item, when, **kwds)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\_pytest\runner.py", line 207, in call_runtest_hook
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\_pytest\runner.py", line 234, in from_call
    result = func()
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\_pytest\runner.py", line 207, in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\_pytest\runner.py", line 131, in pytest_runtest_call
    item.runtest()
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\_pytest\unittest.py", line 207, in runtest
    self._testcase(result=self)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\unittest\case.py", line 663, in __call__
    return self.run(*args, **kwds)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\unittest\case.py", line 611, in run
    self.setUp()
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\seleniumbase\fixtures\base_case.py", line 4296, in setUp
    d_p_r=self.__device_pixel_ratio)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\seleniumbase\fixtures\base_case.py", line 1457, in get_new_driver
    device_pixel_ratio=d_p_r)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\seleniumbase\core\browser_launcher.py", line 370, in get_driver
    device_width, device_height, device_pixel_ratio)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\seleniumbase\core\browser_launcher.py", line 629, in get_local_driver
    return webdriver.Chrome(options=chrome_options)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 319, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 374, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 397, in _request
    resp = self._conn.request(method, url, body=body, headers=headers)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\request.py", line 80, in request
    method, url, fields=fields, headers=headers, **urlopen_kw
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 1321, in getresponse
    response.begin()
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 257, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Users\vdinesh\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
    return self._sock.recv_into(b)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
mdmintz commented 4 years ago

@dineshKumar777 This should be resolved in https://github.com/seleniumbase/SeleniumBase/releases/tag/v1.34.19