Skip to content

Commit 310697d

Browse files
authored
Merge pull request #2166 from seleniumbase/graphics-library-and-colorama-refactoring
Refactor Colorama, update graphics library, and add raw `driver` methods
2 parents 7e3761d + 0431974 commit 310697d

33 files changed

+259
-70
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ pytest test_coffee_cart.py --trace
698698
--dashboard # (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)
699699
--dash-title=STRING # (Set the title shown for the generated dashboard.)
700700
--enable-3d-apis # (Enables WebGL and 3D APIs.)
701-
--swiftshader # (Use Chrome's "--use-gl=swiftshader" feature.)
701+
--swiftshader # (Chrome "--use-gl=angle" / "--use-angle=swiftshader-webgl")
702702
--incognito # (Enable Chrome's Incognito mode.)
703703
--guest # (Enable Chrome's Guest mode.)
704704
--dark # (Enable Chrome's Dark mode.)

examples/raw_parameter_script.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@
117117
sb.proxy_string = None
118118
sb.proxy_bypass_list = None
119119
sb.proxy_pac_url = None
120+
sb._swiftshader = False
120121
sb.multi_proxy = False
121-
sb.swiftshader = False
122122
sb.ad_block_on = False
123123
sb.highlights = None
124124
sb.interval = None

examples/test_chromedriver.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""This test is only for Chrome!
22
(Verify that your chromedriver is compatible with your version of Chrome.)"""
33
import colorama
4+
import sys
45
from seleniumbase import BaseCase
56
BaseCase.main(__name__, __file__)
67

@@ -15,7 +16,13 @@ def test_chromedriver_matches_chrome(self):
1516
major_chrome_version = chrome_version.split(".")[0]
1617
chromedriver_version = self.get_chromedriver_version()
1718
major_chromedriver_version = chromedriver_version.split(".")[0]
18-
colorama.init(autoreset=True)
19+
if (
20+
"win32" in sys.platform
21+
and hasattr(colorama, "just_fix_windows_console")
22+
):
23+
colorama.just_fix_windows_console()
24+
else:
25+
colorama.init(autoreset=True)
1926
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
2027
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
2128
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX

examples/translations/dutch_test_1.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
class MijnTestklasse(Testgeval):
77
def test_voorbeeld_1(self):
88
self.openen("https://nl.wikipedia.org/wiki/Hoofdpagina")
9-
self.controleren_element('a[title*="hoofdpagina gaan"]')
9+
self.controleren_element('a[title*="Welkom voor nieuwkomers"]')
1010
self.controleren_tekst("Welkom op Wikipedia", "td.hp-welkom")
11-
self.typ("#searchInput", "Stroopwafel")
12-
self.klik("#searchButton")
11+
self.typ("#searchform input", "Stroopwafel")
12+
self.klik("#searchform button")
1313
self.controleren_tekst("Stroopwafel", "#firstHeading")
1414
self.controleren_element('img[src*="Stroopwafels"]')
15-
self.typ("#searchInput", "Rijksmuseum Amsterdam")
16-
self.klik("#searchButton")
15+
self.typ("#searchform input", "Rijksmuseum Amsterdam")
16+
self.klik("#searchform button")
1717
self.controleren_tekst("Rijksmuseum", "#firstHeading")
1818
self.controleren_element('img[src*="Rijksmuseum"]')
1919
self.terug()

help_docs/customizing_test_runs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pytest my_first_test.py --settings-file=custom_settings.py
178178
--dashboard # (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)
179179
--dash-title=STRING # (Set the title shown for the generated dashboard.)
180180
--enable-3d-apis # (Enables WebGL and 3D APIs.)
181-
--swiftshader # (Use Chrome's "--use-gl=swiftshader" feature.)
181+
--swiftshader # (Chrome "--use-gl=angle" / "--use-angle=swiftshader-webgl")
182182
--incognito # (Enable Chrome's Incognito mode.)
183183
--guest # (Enable Chrome's Guest mode.)
184184
--dark # (Enable Chrome's Dark mode.)

mkdocs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,6 @@ nav:
180180
extra:
181181
analytics:
182182
provider: google
183-
# property: G-P5KFWRNLRN
184-
property: UA-167313767-1
185-
# google_analytics: ['UA-167313767-1', 'seleniumbase.io']
183+
property: G-P5KFWRNLRN
184+
# property: UA-167313767-1
185+
# google_analytics: ['G-P5KFWRNLRN', 'seleniumbase.io']

mkdocs_build/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# mkdocs dependencies for generating the seleniumbase.io website
22
# Minimum Python version: 3.8 (for generating docs only)
33

4-
regex>=2023.8.8
4+
regex>=2023.10.3
55
PyYAML>=6.0.1
66
pymdown-extensions>=10.3
77
pipdeptree>=2.13.0
88
python-dateutil>=2.8.2
9-
Markdown==3.4.4
9+
Markdown==3.5
1010
markdown2==2.4.10
1111
MarkupSafe==2.1.3
1212
Jinja2==3.1.2
@@ -15,12 +15,12 @@ ghp-import==2.1.0
1515
watchdog==3.0.0
1616
cairocffi==1.6.1
1717
pathspec==0.11.2
18-
Babel==2.12.1
18+
Babel==2.13.0
1919
paginate==0.5.6
2020
pyquery==2.0.0
2121
readtime==3.0.0
2222
mkdocs==1.5.3
23-
mkdocs-material==9.4.2
23+
mkdocs-material==9.4.4
2424
mkdocs-exclude-search==0.6.5
2525
mkdocs-simple-hooks==0.1.5
2626
mkdocs-material-extensions==1.2

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ attrs>=23.1.0
77
certifi>=2023.7.22
88
filelock>=3.12.2;python_version<"3.8"
99
filelock>=3.12.4;python_version>="3.8"
10-
platformdirs>=3.10.0
10+
platformdirs>=3.11.0
1111
parse>=1.19.1
1212
parse-type>=0.6.2
1313
six==1.16.0
@@ -63,7 +63,7 @@ rich==13.6.0
6363

6464
coverage==6.2;python_version<"3.7"
6565
coverage==7.2.7;python_version>="3.7" and python_version<"3.8"
66-
coverage==7.3.1;python_version>="3.8"
66+
coverage==7.3.2;python_version>="3.8"
6767
pytest-cov==4.0.0;python_version<"3.7"
6868
pytest-cov==4.1.0;python_version>="3.7"
6969
flake8==5.0.4;python_version<"3.9"

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__ = "4.19.1"
2+
__version__ = "4.19.2"

seleniumbase/behave/behave_sb.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@
111111
from seleniumbase.fixtures import constants
112112
from seleniumbase.fixtures import shared_utils
113113

114+
is_linux = shared_utils.is_linux()
115+
is_windows = shared_utils.is_windows()
114116
sb_config.__base_class = None
115117

116118

@@ -829,10 +831,10 @@ def get_configured_sb(context):
829831
'\n (Your browser choice was: "%s")\n' % sb.browser
830832
)
831833
# The Xvfb virtual display server is for Linux OS Only.
832-
if sb.xvfb and not shared_utils.is_linux():
834+
if sb.xvfb and not is_linux:
833835
sb.xvfb = False
834836
if (
835-
shared_utils.is_linux()
837+
is_linux
836838
and not sb.headed
837839
and not sb.headless
838840
and not sb.headless2
@@ -1020,7 +1022,7 @@ def dashboard_pre_processing():
10201022
filename = None
10211023
feature_name = None
10221024
scenario_name = None
1023-
if shared_utils.is_windows():
1025+
if is_windows:
10241026
output = output.decode("latin1")
10251027
else:
10261028
output = output.decode("utf-8")
@@ -1129,8 +1131,11 @@ def behave_dashboard_prepare():
11291131
stars = "*" * star_len
11301132
c1 = ""
11311133
cr = ""
1132-
if not shared_utils.is_linux():
1133-
colorama.init(autoreset=True)
1134+
if not is_linux:
1135+
if is_windows and hasattr(colorama, "just_fix_windows_console"):
1136+
colorama.just_fix_windows_console()
1137+
else:
1138+
colorama.init(autoreset=True)
11341139
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
11351140
cr = colorama.Style.RESET_ALL
11361141
print("Dashboard: %s%s%s\n%s" % (c1, dash_path, cr, stars))
@@ -1144,7 +1149,7 @@ def _perform_behave_unconfigure_():
11441149
if sb_config.shared_driver:
11451150
try:
11461151
if (
1147-
not shared_utils.is_windows()
1152+
not is_windows
11481153
or sb_config.browser == "ie"
11491154
or sb_config.shared_driver.service.process
11501155
):
@@ -1221,7 +1226,7 @@ def do_final_driver_cleanup_as_needed():
12211226
try:
12221227
if hasattr(sb_config, "last_driver") and sb_config.last_driver:
12231228
if (
1224-
not shared_utils.is_windows()
1229+
not is_windows
12251230
or sb_config.browser == "ie"
12261231
or sb_config.last_driver.service.process
12271232
):
@@ -1245,8 +1250,11 @@ def _perform_behave_terminal_summary_():
12451250
equals = "=" * (equals_len + 2)
12461251
c2 = ""
12471252
cr = ""
1248-
if not shared_utils.is_linux():
1249-
colorama.init(autoreset=True)
1253+
if not is_linux:
1254+
if is_windows and hasattr(colorama, "just_fix_windows_console"):
1255+
colorama.just_fix_windows_console()
1256+
else:
1257+
colorama.init(autoreset=True)
12501258
c2 = colorama.Fore.MAGENTA + colorama.Back.LIGHTYELLOW_EX
12511259
cr = colorama.Style.RESET_ALL
12521260
if sb_config.dashboard:

0 commit comments

Comments
 (0)