Skip to content

Commit 62300a4

Browse files
authored
Merge pull request #958 from seleniumbase/updates-and-refactoring
Updates and refactoring
2 parents 92e49fe + f80b9a5 commit 62300a4

File tree

14 files changed

+169
-63
lines changed

14 files changed

+169
-63
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/">
99
<img src="https://seleniumbase.io/cdn/img/logo_and_pie.png" alt="SeleniumBase" title="SeleniumBase" width="690" /></a></p>
1010
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/releases">
11-
<img src="https://img.shields.io/github/v/release/seleniumbase/SeleniumBase.svg?color=0090c0" alt="Latest Release on GitHub" /></a> <a href="https://pypi.org/project/seleniumbase/">
11+
<img src="https://img.shields.io/badge/View Releases-%20GitHub-0090c0.svg" alt="SeleniumBase.io Docs" /></a> <a href="https://pypi.org/project/seleniumbase/">
1212
<img src="https://img.shields.io/pypi/v/seleniumbase.svg?color=00a0e0" alt="Latest Release on PyPI" /></a></p>
1313
<p align="center">
1414
<b>Python Web-UI Testing Made Awesome.</b>
@@ -50,9 +50,9 @@
5050
</p>
5151

5252
<p align="left">
53-
✅ SeleniumBase is a Python framework for web testing.<br / >
54-
✅ Tests can be run with <b>pytest</b> from the command-line.<br / >
55-
✅ Includes code to simplify & improve WebDriver APIs.<br / >
53+
✅ SeleniumBase is a Python framework for web testing.<br />
54+
✅ Tests can be run with <b>pytest</b> from the command-line.<br />
55+
✅ Includes code to simplify & improve WebDriver APIs.<br />
5656
✅ Supports Chrome, Edge, Firefox, IE, Opera, and Safari.<br />
5757
✅ Includes powerful <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md">reporting and dashboard features</a>.
5858
</p>
@@ -907,7 +907,7 @@ self.execute_script('''document.body.innerHTML = \"%s\"''' % referral_link)
907907
self.click("a.analytics") # Clicks the generated button
908908
```
909909
910-
(Due to popular demand, this traffic generation example has been baked into SeleniumBase with the ``self.generate_referral(start_page, end_page)`` and the ``self.generate_traffic(start_page, end_page, loops)`` methods.)
910+
(Due to popular demand, this traffic generation example has been included in SeleniumBase with the ``self.generate_referral(start_page, end_page)`` and the ``self.generate_traffic(start_page, end_page, loops)`` methods.)
911911
912912
🔵 Using deferred asserts:
913913

examples/visual_testing/layout_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_applitools_layout_change(self):
1919
self.click("button")
2020
self.check_window(name="helloworld", level=1)
2121
self.check_window(name="helloworld", level=2)
22-
with self.assertRaises(Exception):
22+
with self.assert_raises(Exception):
2323
self.check_window(name="helloworld", level=3)
2424
# Now that we know the Exception was raised as expected,
2525
# let's print out the comparison results by running a Level-0 check.

examples/youtube_search_test.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from seleniumbase import BaseCase
2+
3+
4+
class YouTubeSearchTests(BaseCase):
5+
def test_youtube_autocomplete_results(self):
6+
""" Verify YouTube autocomplete search results. """
7+
self.open("https://www.youtube.com/")
8+
search_term = "seleniumbase"
9+
search_selector = "input#search"
10+
result_selector = 'li[role="presentation"] b'
11+
self.double_click(search_selector)
12+
self.type(search_selector, search_term)
13+
# First verify that an autocomplete result exists
14+
self.assert_element(result_selector)
15+
top_result = self.get_text(result_selector)
16+
# Now verify that the autocomplete result is good
17+
self.assert_true(
18+
search_term in top_result,
19+
'Expected text "%s" not found in top result! '
20+
'Actual text was "%s"!'
21+
% (search_term, top_result)
22+
)
23+
24+
def test_youtube_search_results(self):
25+
""" Verify finding a specific video by performing a YouTube search. """
26+
self.open("https://www.youtube.com/")
27+
search_term = "SeleniumBase Common API Methods"
28+
search_selector = "input#search"
29+
self.type(search_selector, search_term + "\n")
30+
self.ad_block()
31+
self.demo_mode = True
32+
self.assert_element('.text-wrapper > div:contains("%s")' % search_term)

help_docs/customizing_test_runs.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ pytest test_demo_site.py --headless
2222
# Run tests multi-threaded using [n] threads
2323
pytest test_suite.py -n=4
2424

25+
# Reuse the browser session for all tests being run
26+
pytest test_suite.py --reuse-session
27+
28+
# Reuse the browser session, but empty cookies between tests
29+
pytest test_suite.py --reuse-session --crumbs
30+
31+
# Create a real-time dashboard for test results
32+
pytest test_suite.py --dashboard
33+
2534
# Create a pytest html report after tests are done
2635
pytest test_suite.py --html=report.html
2736

@@ -43,12 +52,6 @@ pytest test_suite.py --server=IP_ADDRESS --port=4444
4352
# Run tests on a remote Selenium Grid with authentication
4453
pytest test_suite.py --server=USERNAME:KEY@IP_ADDRESS --port=80
4554

46-
# Reuse the same browser session for all tests being run
47-
pytest test_suite.py --reuse-session
48-
49-
# Reuse the same browser session, but empty cookies between tests
50-
pytest test_suite.py --reuse-session --crumbs
51-
5255
# Run tests through a proxy server
5356
pytest proxy_test.py --proxy=IP_ADDRESS:PORT
5457

help_docs/method_summary.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ self.assert_equal(first, second, msg=None)
350350

351351
self.assert_not_equal(first, second, msg=None)
352352

353+
self.assert_in(first, second, msg=None)
354+
355+
self.assert_not_in(first, second, msg=None)
356+
353357
self.assert_raises(*args, **kwargs)
354358

355359
self.wait_for_attribute(

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pip>=20.3.4;python_version<"3.6"
2-
pip>=21.2.2;python_version>="3.6"
2+
pip>=21.2.3;python_version>="3.6"
33
packaging>=20.9;python_version<"3.6"
44
packaging>=21.0;python_version>="3.6"
55
typing-extensions>=3.10.0.0
@@ -8,7 +8,7 @@ setuptools>=50.3.2;python_version>="3.5" and python_version<"3.6"
88
setuptools>=57.4.0;python_version>="3.6"
99
setuptools-scm==5.0.2;python_version<"3.6"
1010
setuptools-scm>=6.0.1;python_version>="3.6"
11-
wheel>=0.36.2
11+
wheel>=0.37.0
1212
attrs>=21.2.0
1313
PyYAML>=5.4.1;python_version>="3.6"
1414
sortedcontainers==2.4.0
@@ -86,7 +86,7 @@ platformdirs==2.0.2;python_version<"3.6"
8686
platformdirs==2.2.0;python_version>="3.6"
8787
pathlib2==2.3.5;python_version<"3.5"
8888
importlib-metadata==2.0.0;python_version<"3.6"
89-
virtualenv>=20.7.0
89+
virtualenv>=20.7.1
9090
pymysql==0.10.1;python_version<"3.6"
9191
pymysql==1.0.2;python_version>="3.6"
9292
pyotp==2.6.0

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__ = "1.63.21"
2+
__version__ = "1.63.22"

seleniumbase/config/ad_block_list.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,5 @@
107107
"img.img_ad",
108108
'link[href*="/adservice."]',
109109
"section.dianomi-ad",
110+
"ytd-promoted-video-renderer",
110111
]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from rich.console import Console
2+
from rich.markdown import Markdown
3+
from rich.syntax import Syntax
4+
5+
6+
def process_syntax(code, lang, theme, line_numbers, code_width, word_wrap):
7+
syntax = Syntax(
8+
code,
9+
lang,
10+
theme=theme,
11+
line_numbers=line_numbers,
12+
code_width=code_width,
13+
word_wrap=word_wrap,
14+
)
15+
return syntax
16+
17+
18+
def display_markdown(code):
19+
try:
20+
markdown = Markdown(code)
21+
console = Console()
22+
console.print(markdown) # noqa
23+
return True # Success
24+
except Exception:
25+
return False # Failure
26+
27+
28+
def display_code(code):
29+
try:
30+
console = Console()
31+
console.print(code) # noqa
32+
return True # Success
33+
except Exception:
34+
return False # Failure
35+
36+
37+
def fix_emoji_spacing(code):
38+
try:
39+
# Fix the display width of certain emojis that take up two spaces
40+
double_width_emojis = ["🗺️", "🖼️", "🗄️", "⏺️", "♻️", "🗂️", "🖥️"]
41+
for emoji in double_width_emojis:
42+
if emoji in code:
43+
code = code.replace(emoji, emoji + " ")
44+
except Exception:
45+
pass
46+
return code

seleniumbase/console_scripts/run.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -760,14 +760,6 @@ def main():
760760
show_convert_usage()
761761
elif command == "print":
762762
if len(command_args) >= 1:
763-
if sys.version_info[0] == 2:
764-
c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
765-
cr = colorama.Style.RESET_ALL
766-
msg = '"sbase print" does NOT support Python 2! '
767-
msg += 'Try using the Unix "cat" command instead!'
768-
message = "\n" + c5 + msg + cr + "\n"
769-
print("")
770-
raise Exception(message)
771763
from seleniumbase.console_scripts import sb_print
772764

773765
sb_print.main()

0 commit comments

Comments
 (0)