Skip to content

Commit 0d1de72

Browse files
authored
Merge pull request #1167 from seleniumbase/active-window-visibility-and-more
Active window visibility and more
2 parents 26633fb + f186c56 commit 0d1de72

File tree

7 files changed

+44
-13
lines changed

7 files changed

+44
-13
lines changed

examples/test_multiple_drivers.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from seleniumbase import BaseCase
2+
3+
4+
class MultipleDriversTest(BaseCase):
5+
def test_multiple_drivers(self):
6+
self.open("data:text/html,<h1>Driver 1</h1>")
7+
driver2 = self.get_new_driver()
8+
self.open("data:text/html,<h1>Driver 2</h1>")
9+
self.switch_to_default_driver() # Driver 1
10+
self.highlight("h1")
11+
self.assert_text("Driver 1", "h1")
12+
self.switch_to_driver(driver2) # Driver 2
13+
self.highlight("h1")
14+
self.assert_text("Driver 2", "h1")

help_docs/method_summary.md

+2
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ self.save_recorded_actions()
265265

266266
self.activate_jquery()
267267

268+
self.bring_active_window_to_front()
269+
268270
self.bring_to_front(selector, by=By.CSS_SELECTOR)
269271

270272
self.highlight_click(selector, by=By.CSS_SELECTOR, loops=3, scroll=True)

requirements.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ packaging>=21.3;python_version>="3.6"
55
setuptools>=44.1.1;python_version<"3.5"
66
setuptools>=50.3.2;python_version>="3.5" and python_version<"3.6"
77
setuptools>=59.6.0;python_version>="3.6" and python_version<"3.7"
8-
setuptools>=60.2.0;python_version>="3.7"
8+
setuptools>=60.3.1;python_version>="3.7"
99
setuptools-scm>=5.0.2;python_version<"3.6"
1010
setuptools-scm>=6.3.2;python_version>="3.6"
1111
tomli>=1.2.2;python_version>="3.6" and python_version<"3.7"
@@ -28,7 +28,7 @@ idna==3.3;python_version>="3.6"
2828
chardet==3.0.4;python_version<"3.5"
2929
chardet==4.0.0;python_version>="3.5"
3030
charset-normalizer==2.0.10;python_version>="3.5"
31-
urllib3==1.26.7
31+
urllib3==1.26.8
3232
requests==2.27.0;python_version<"3.5"
3333
requests==2.25.1;python_version>="3.5" and python_version<"3.6"
3434
requests==2.27.1;python_version>="3.6"
@@ -83,12 +83,12 @@ cryptography==3.2.1;python_version>="3.5" and python_version<"3.6"
8383
cryptography==3.4.8;python_version>="3.6" and python_version<"3.7"
8484
cryptography==36.0.1;python_version>="3.7"
8585
pygments==2.5.2;python_version<"3.5"
86-
pygments==2.11.1;python_version>="3.5"
86+
pygments==2.11.2;python_version>="3.5"
8787
prompt-toolkit==1.0.18;python_version<"3.5"
8888
prompt-toolkit==2.0.10;python_version>="3.5" and python_version<"3.6.2"
8989
prompt-toolkit==3.0.24;python_version>="3.6.2"
9090
decorator==4.4.2;python_version<"3.5"
91-
decorator==5.1.0;python_version>="3.5"
91+
decorator==5.1.1;python_version>="3.5"
9292
ipython==5.10.0;python_version<"3.5"
9393
ipython==7.9.0;python_version>="3.5" and python_version<"3.6"
9494
ipython==7.16.1;python_version>="3.6" and python_version<"3.7"

seleniumbase/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "2.3.9"
2+
__version__ = "2.3.10"

seleniumbase/fixtures/base_case.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -2986,13 +2986,15 @@ def switch_to_driver(self, driver):
29862986
self.driver = driver
29872987
if self.driver in self.__driver_browser_map:
29882988
self.browser = self.__driver_browser_map[self.driver]
2989+
self.bring_active_window_to_front()
29892990

29902991
def switch_to_default_driver(self):
29912992
""" Sets self.driver to the default/original driver. """
29922993
self.__check_scope()
29932994
self.driver = self._default_driver
29942995
if self.driver in self.__driver_browser_map:
29952996
self.browser = self.__driver_browser_map[self.driver]
2997+
self.bring_active_window_to_front()
29962998

29972999
def save_screenshot(
29983000
self, name, folder=None, selector=None, by=By.CSS_SELECTOR
@@ -3183,7 +3185,10 @@ def wait_for_angularjs(self, timeout=None, **kwargs):
31833185

31843186
def sleep(self, seconds):
31853187
self.__check_scope()
3186-
if not sb_config.time_limit:
3188+
if (
3189+
not hasattr(sb_config, "time_limit")
3190+
or (hasattr(sb_config, "time_limit") and not sb_config.time_limit)
3191+
):
31873192
time.sleep(seconds)
31883193
elif seconds < 0.4:
31893194
shared_utils.check_if_time_limit_exceeded()
@@ -3890,6 +3895,15 @@ def __are_quotes_escaped(self, string):
38903895
def __escape_quotes_if_needed(self, string):
38913896
return js_utils.escape_quotes_if_needed(string)
38923897

3898+
def bring_active_window_to_front(self):
3899+
"""Brings the active browser window to the front.
3900+
This is useful when multiple drivers are being used."""
3901+
self.__check_scope()
3902+
try:
3903+
self.switch_to_window(self.driver.current_window_handle)
3904+
except Exception:
3905+
pass
3906+
38933907
def bring_to_front(self, selector, by=By.CSS_SELECTOR):
38943908
"""Updates the Z-index of a page element to bring it into view.
38953909
Useful when getting a WebDriverException, such as the one below:
@@ -10466,7 +10480,7 @@ def __click_dropdown_partial_link_text(self, link_text, link_css):
1046610480
def __recalculate_selector(self, selector, by, xp_ok=True):
1046710481
"""Use autodetection to return the correct selector with "by" updated.
1046810482
If "xp_ok" is False, don't call convert_css_to_xpath(), which is
10469-
used to make the ":contains()" selector valid outside JS calls."""
10483+
used to make the ":contains()" selector valid outside of JS calls."""
1047010484
_type = type(selector) # First make sure the selector is a string
1047110485
not_string = False
1047210486
if not python3:

seleniumbase/fixtures/js_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ def set_messenger_theme(
599599
theme = "flat"
600600
if location == "default":
601601
location = "bottom_right"
602-
if sb_config.mobile_emulator:
602+
if hasattr(sb_config, "mobile_emulator") and sb_config.mobile_emulator:
603603
location = "top_center"
604604
if max_messages == "default":
605605
max_messages = "8"
@@ -682,7 +682,7 @@ def post_messenger_success_message(driver, message, msg_dur):
682682
try:
683683
theme = "flat"
684684
location = "bottom_right"
685-
if sb_config.mobile_emulator:
685+
if hasattr(sb_config, "mobile_emulator") and sb_config.mobile_emulator:
686686
location = "top_center"
687687
set_messenger_theme(driver, theme=theme, location=location)
688688
post_message(driver, message, msg_dur, style="success")

setup.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
author_email="[email protected]",
8484
maintainer="Michael Mintz",
8585
license="MIT",
86+
keywords="pytest automation selenium browser testing webdriver sbase",
8687
classifiers=[
8788
"Development Status :: 5 - Production/Stable",
8889
"Environment :: Console",
@@ -125,7 +126,7 @@
125126
'setuptools>=44.1.1;python_version<"3.5"',
126127
'setuptools>=50.3.2;python_version>="3.5" and python_version<"3.6"',
127128
'setuptools>=59.6.0;python_version>="3.6" and python_version<"3.7"',
128-
'setuptools>=60.2.0;python_version>="3.7"',
129+
'setuptools>=60.3.1;python_version>="3.7"',
129130
'setuptools-scm>=5.0.2;python_version<"3.6"',
130131
'setuptools-scm>=6.3.2;python_version>="3.6"',
131132
'tomli>=1.2.2;python_version>="3.6" and python_version<"3.7"',
@@ -148,7 +149,7 @@
148149
'chardet==3.0.4;python_version<"3.5"', # Stay in sync with "requests"
149150
'chardet==4.0.0;python_version>="3.5"', # Stay in sync with "requests"
150151
'charset-normalizer==2.0.10;python_version>="3.5"', # Sync "requests"
151-
"urllib3==1.26.7", # Must stay in sync with "requests"
152+
"urllib3==1.26.8", # Must stay in sync with "requests"
152153
'requests==2.27.0;python_version<"3.5"',
153154
'requests==2.25.1;python_version>="3.5" and python_version<"3.6"',
154155
'requests==2.27.1;python_version>="3.6"',
@@ -203,12 +204,12 @@
203204
'cryptography==3.4.8;python_version>="3.6" and python_version<"3.7"',
204205
'cryptography==36.0.1;python_version>="3.7"',
205206
'pygments==2.5.2;python_version<"3.5"',
206-
'pygments==2.11.1;python_version>="3.5"',
207+
'pygments==2.11.2;python_version>="3.5"',
207208
'prompt-toolkit==1.0.18;python_version<"3.5"',
208209
'prompt-toolkit==2.0.10;python_version>="3.5" and python_version<"3.6.2"', # noqa: E501
209210
'prompt-toolkit==3.0.24;python_version>="3.6.2"',
210211
'decorator==4.4.2;python_version<"3.5"',
211-
'decorator==5.1.0;python_version>="3.5"',
212+
'decorator==5.1.1;python_version>="3.5"',
212213
'ipython==5.10.0;python_version<"3.5"',
213214
'ipython==7.9.0;python_version>="3.5" and python_version<"3.6"',
214215
'ipython==7.16.1;python_version>="3.6" and python_version<"3.7"',

0 commit comments

Comments
 (0)