Skip to content

Commit 666a70d

Browse files
authored
Merge pull request #1265 from seleniumbase/fix-issue-with-sb-pdb-during-failures
Fix "sb" fixture issue that occurs with "--pdb" on failures
2 parents ea61c9c + 82599bb commit 666a70d

File tree

10 files changed

+85
-20
lines changed

10 files changed

+85
-20
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ pip install -e . # Editable install
7878

7979
> (When using a virtual env, the Editable install is faster.)
8080
81+
To upgrade an existing install from a GitHub clone:
82+
83+
```bash
84+
git pull # To pull the latest version
85+
pip install -e . # Or "pip install ."
86+
```
87+
8188
🔵 Installing ``seleniumbase`` from PyPI:
8289

8390
```bash
@@ -88,6 +95,12 @@ pip install seleniumbase
8895
> (Add ``--force-reinstall`` to also install the latest dependencies.)
8996
> (Use ``pip3`` if multiple versions of Python are installed.)
9097
98+
To upgrade an existing install from PyPI:
99+
100+
```bash
101+
pip install -U seleniumbase
102+
```
103+
91104
🔵 Type ``seleniumbase`` or ``sbase`` to verify that SeleniumBase was installed successfully:
92105

93106
```bash

examples/xpath_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ def test_xpath(self):
77
self.assert_element('//h1[(text()="Demo Page")]')
88
self.type('//*[@id="myTextInput"]', "XPath Test!")
99
self.click('//button[starts-with(text(),"Click Me")]')
10+
self.assert_element('//button[contains(., "Purple")]')
1011
self.assert_text("SeleniumBase", '//table/tbody/tr[1]/td[2]/h2')

help_docs/install.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
pip install seleniumbase
99
```
1010

11+
To upgrade an existing ``seleniumbase`` install from PyPI:
12+
13+
```bash
14+
pip install -U seleniumbase
15+
```
16+
1117
<h4>If installing SeleniumBase from a Git clone, use:</h4>
1218

1319
```bash
@@ -24,6 +30,13 @@ cd SeleniumBase/
2430
pip install -e .
2531
```
2632

33+
To upgrade an existing ``seleniumbase`` install from GitHub:
34+
35+
```bash
36+
git pull # To pull the latest version
37+
pip install -e . # Or "pip install ."
38+
```
39+
2740
<h4>If installing SeleniumBase from a <a href="https://github.com/seleniumbase/SeleniumBase">GitHub branch</a>, use:</h4>
2841

2942
```bash

mkdocs_build/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pyparsing==3.0.7
1313
keyring==23.5.0
1414
pkginfo==1.8.2
1515
Jinja2==3.1.1
16-
click==8.0.4
16+
click==8.1.2
1717
zipp==3.7.0
1818
readme-renderer==34.0
1919
pymdown-extensions==9.3

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ packaging>=21.3;python_version>="3.6"
66
setuptools>=44.1.1;python_version<"3.5"
77
setuptools>=50.3.2;python_version>="3.5" and python_version<"3.6"
88
setuptools>=59.6.0;python_version>="3.6" and python_version<"3.7"
9-
setuptools>=61.1.1;python_version>="3.7"
9+
setuptools>=61.3.0;python_version>="3.7"
1010
setuptools-scm>=5.0.2;python_version<"3.6"
1111
setuptools-scm>=6.4.2;python_version>="3.6"
1212
tomli>=1.2.3;python_version>="3.6" and python_version<"3.7"

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "2.4.27"
2+
__version__ = "2.4.28"

seleniumbase/console_scripts/sb_mkdir.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ def main():
274274
data.append("saved_cookies")
275275
data.append("recordings")
276276
data.append("visual_baseline")
277+
data.append(".DS_Store")
277278
data.append("selenium-server-standalone.jar")
278279
data.append("proxy.zip")
279280
data.append("proxy.lock")

seleniumbase/fixtures/base_case.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11173,6 +11173,8 @@ def setUp(self, masterqa_mode=False):
1117311173
self.test_id = test_id
1117411174
if hasattr(self, "_using_sb_fixture"):
1117511175
self.test_id = sb_config._test_id
11176+
if hasattr(sb_config, "_sb_pdb_driver"):
11177+
sb_config._sb_pdb_driver = None
1117611178
self.browser = sb_config.browser
1117711179
self.account = sb_config.account
1117811180
self.data = sb_config.data
@@ -11685,6 +11687,21 @@ def __add_pytest_html_extra(self):
1168511687
except Exception:
1168611688
pass
1168711689

11690+
def __delay_driver_quit(self):
11691+
delay_driver_quit = False
11692+
if (
11693+
hasattr(self, "_using_sb_fixture")
11694+
and self._using_sb_fixture
11695+
and "--pdb" in sys.argv
11696+
and self.__has_exception()
11697+
and len(self._drivers_list) == 1
11698+
and self.driver == self._default_driver
11699+
):
11700+
# Special case: Using sb fixture, --pdb, and has error.
11701+
# Keep the driver open for debugging and quit it later.
11702+
delay_driver_quit = True
11703+
return delay_driver_quit
11704+
1168811705
def __quit_all_drivers(self):
1168911706
if self._reuse_session and sb_config.shared_driver:
1169011707
if len(self._drivers_list) > 0:
@@ -11698,20 +11715,25 @@ def __quit_all_drivers(self):
1169811715
self._drivers_list = self._drivers_list[1:]
1169911716
else:
1170011717
self._drivers_list = []
11701-
1170211718
# Close all open browser windows
11719+
delay_driver_quit = self.__delay_driver_quit()
1170311720
self._drivers_list.reverse() # Last In, First Out
1170411721
for driver in self._drivers_list:
1170511722
try:
1170611723
if not is_windows or driver.service.process:
11707-
driver.quit()
11724+
if not delay_driver_quit:
11725+
driver.quit()
11726+
else:
11727+
# Save it for later to quit it later.
11728+
sb_config._sb_pdb_driver = driver
1170811729
except AttributeError:
1170911730
pass
1171011731
except Exception:
1171111732
pass
11712-
self.driver = None
11713-
self._default_driver = None
11714-
self._drivers_list = []
11733+
if not delay_driver_quit:
11734+
self.driver = None
11735+
self._default_driver = None
11736+
self._drivers_list = []
1171511737

1171611738
def __has_exception(self):
1171711739
has_exception = False

seleniumbase/plugins/pytest_plugin.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,17 +1345,32 @@ def pytest_runtest_teardown(item):
13451345
Make sure that webdriver and headless displays have exited.
13461346
(Has zero effect on tests using --reuse-session / --rs)"""
13471347
try:
1348-
self = item._testcase
1349-
try:
1350-
if (
1351-
hasattr(self, "driver")
1352-
and self.driver
1353-
and "--pdb" not in sys.argv
1348+
if hasattr(item, "_testcase") or hasattr(sb_config, "_sb_pdb_driver"):
1349+
if hasattr(item, "_testcase"):
1350+
self = item._testcase
1351+
try:
1352+
if (
1353+
hasattr(self, "driver")
1354+
and self.driver
1355+
and "--pdb" not in sys.argv
1356+
):
1357+
if not is_windows or self.driver.service.process:
1358+
self.driver.quit()
1359+
except Exception:
1360+
pass
1361+
elif (
1362+
hasattr(sb_config, "_sb_pdb_driver")
1363+
and sb_config._sb_pdb_driver
13541364
):
1355-
if not is_windows or self.driver.service.process:
1356-
self.driver.quit()
1357-
except Exception:
1358-
pass
1365+
try:
1366+
if (
1367+
not is_windows
1368+
or sb_config._sb_pdb_driver.service.process
1369+
):
1370+
sb_config._sb_pdb_driver.quit()
1371+
sb_config._sb_pdb_driver = None
1372+
except Exception:
1373+
pass
13591374
try:
13601375
if hasattr(self, "xvfb") and self.xvfb:
13611376
if self.headless_active and "--pdb" not in sys.argv:

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
print("\n*** Installing build: *** (Required for PyPI uploads)\n")
5050
os.system("python -m pip install --upgrade 'build>=0.7.0'")
5151
print("\n*** Installing twine: *** (Required for PyPI uploads)\n")
52-
os.system("python -m pip install --upgrade 'twine>=3.8.0'")
52+
os.system("python -m pip install --upgrade 'twine>=4.0.0'")
5353
print("\n*** Installing tqdm: *** (Required for PyPI uploads)\n")
5454
os.system("python -m pip install --upgrade 'tqdm>=4.63.1'")
5555
print("\n*** Rebuilding distribution packages: ***\n")
@@ -131,7 +131,7 @@
131131
'setuptools>=44.1.1;python_version<"3.5"',
132132
'setuptools>=50.3.2;python_version>="3.5" and python_version<"3.6"',
133133
'setuptools>=59.6.0;python_version>="3.6" and python_version<"3.7"',
134-
'setuptools>=61.1.1;python_version>="3.7"',
134+
'setuptools>=61.3.0;python_version>="3.7"',
135135
'setuptools-scm>=5.0.2;python_version<"3.6"',
136136
'setuptools-scm>=6.4.2;python_version>="3.6"',
137137
'tomli>=1.2.3;python_version>="3.6" and python_version<"3.7"',

0 commit comments

Comments
 (0)