Skip to content

Commit d570ae8

Browse files
authored
Merge pull request #1084 from seleniumbase/shadow-dom-overhaul-and-more
Shadow DOM overhaul and more
2 parents e20ffe2 + 47376a3 commit d570ae8

File tree

13 files changed

+189
-44
lines changed

13 files changed

+189
-44
lines changed

examples/desktop_apps/ReadMe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<h3 align="left"><img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" alt="SeleniumBase" width="320" /></h3>
2+
3+
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Desktop Apps</h2>
4+
5+
* **Recorder** (Run using ``python recorder.py``)

examples/desktop_apps/recorder.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
""" Run this file using `python recorder.py` """
2+
3+
import os
4+
import sys
5+
from seleniumbase.fixtures import page_utils
6+
7+
if sys.version_info[0] < 3:
8+
raise Exception("This script is for Python 3 only!")
9+
import tkinter as tk # noqa: E402
10+
from tkinter import messagebox # noqa: E402
11+
12+
13+
def do_recording(file_name, url):
14+
url = url.strip()
15+
if not page_utils.is_valid_url(url):
16+
if page_utils.is_valid_url("https://" + url):
17+
url = "https://" + url
18+
if not page_utils.is_valid_url(url):
19+
messagebox.showwarning(
20+
"Invalid URL", "Enter a valid URL. (Eg. https://google.com)")
21+
else:
22+
if os.path.exists(file_name):
23+
os.remove(file_name)
24+
os.system("python -m sbase mkrec %s --url=%s" % (file_name, url))
25+
26+
27+
def do_playback(file_name):
28+
os.system("pytest %s --verbose --capture=no" % file_name)
29+
30+
31+
def create_tkinter_gui(file_name):
32+
window = tk.Tk()
33+
window.title("Recorder App")
34+
window.geometry("360x175")
35+
frame = tk.Frame(window)
36+
frame.pack()
37+
38+
a = tk.StringVar()
39+
tk.Label(window, text="Enter URL to start recording on:").pack()
40+
entry = tk.Entry(window, textvariable=a)
41+
entry.pack()
42+
entry.focus()
43+
entry.bind("<Return>", (lambda _: do_recording(file_name, a.get())))
44+
tk.Button(
45+
window, text="Record", command=lambda: do_recording(file_name, a.get())
46+
).pack()
47+
tk.Label(window, text="").pack()
48+
tk.Label(
49+
window, text="Playback the latest recording:").pack()
50+
tk.Button(
51+
window, text="Playback", command=lambda: do_playback(file_name)
52+
).pack()
53+
54+
# Bring form to front
55+
window.lift()
56+
window.attributes("-topmost", True)
57+
window.after_idle(window.attributes, "-topmost", False)
58+
window.mainloop()
59+
60+
61+
if __name__ == "__main__":
62+
file_name = "new_recording.py"
63+
create_tkinter_gui(file_name)

examples/shadow_root_test.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1+
""" Piercing through shadow-root elements with the "::shadow" selector.
2+
To confirm that "::shadow" works, print text and assert exact text. """
3+
14
from seleniumbase import BaseCase
25

36

47
class ShadowRootTest(BaseCase):
58
def test_shadow_root(self):
6-
self.open("https://react-shadow.herokuapp.com/Patagonia")
7-
self.click("section.weather::shadow div::shadow button")
8-
self.assert_element('section.weather::shadow img[alt="Patagonia"]')
9-
weather = self.get_text("section.weather::shadow h1")
10-
self.post_message(weather)
11-
self.click('section.weather::shadow a[href="/Kyoto"]')
12-
self.assert_element('section.weather::shadow img[alt="Kyoto"]')
13-
weather = self.get_text("section.weather::shadow h1")
14-
self.post_message(weather)
9+
self.open("https://seleniumbase.io/other/shadow_dom")
10+
print("")
11+
self.click("button.tab_1")
12+
print(self.get_text("fancy-tabs::shadow #panels"))
13+
self.assert_exact_text("Content Panel 1", "fancy-tabs::shadow #panels")
14+
self.click("button.tab_2")
15+
print(self.get_text("fancy-tabs::shadow #panels"))
16+
self.assert_exact_text("Content Panel 2", "fancy-tabs::shadow #panels")
17+
self.click("button.tab_3")
18+
print(self.get_text("fancy-tabs::shadow #panels"))
19+
self.assert_exact_text("Content Panel 3", "fancy-tabs::shadow #panels")

examples/decryption_test.py renamed to examples/test_decryption.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
This test demonstrates the use of encryption/decryption.
3-
(Technically, obfuscation/unobfuscation of passwords.)
2+
This test demonstrates the use of password encryption/decryption.
3+
(Technically considered to be obfuscation/unobfuscation.)
44
"""
55

66
from seleniumbase import BaseCase

help_docs/ReadMe.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,16 @@
7878
<div><a href="https://seleniumbase.io/tinymce/"><b>TinyMCE (Test Page)</b></a></div>
7979
<div><a href="https://seleniumbase.io/error_page/"><b>Error Page (Test Page)</b></a></div>
8080
<div><a href="https://seleniumbase.io/other/drag_and_drop"><b>Drag-&-Drop (Test Page)</b></a></div>
81-
<div><a href="https://seleniumbase.io/devices/"><b>Virtual Device Farm</b></a></div>
81+
<div><a href="https://seleniumbase.io/devices/"><b>Device Farm (Virtual)</b></a></div>
8282
<div><a href="https://seleniumbase.io/w3schools/"><b>HTML Playground Page</b></a></div>
8383
<div><a href="https://seleniumbase.io/w3schools/sbase"><b>SeleniumBase in iframe</b></a></div>
8484
<div><a href="https://seleniumbase.io/other/broken_page"><b>Page with broken links</b></a></div>
85+
<div><a href="https://seleniumbase.io/other/shadow_dom"><b>Shadow DOM/Root</b></a></div>
8586
<div><a href="https://seleniumbase.io/w3schools/iframes"><b>W3Schools iframes</b></a></div>
87+
<div><a href="https://seleniumbase.io/w3schools/file_upload"><b>W3Schools file upload</b></a></div>
8688
<div><a href="https://seleniumbase.io/w3schools/double_click"><b>W3Schools doubleclick</b></a></div>
87-
<div><a href="https://seleniumbase.io/w3schools/checkboxes"><b>W3Schools checkboxes</b></a></div>
8889
<div><a href="https://seleniumbase.io/w3schools/drag_drop"><b>W3Schools drag & drop</b></a></div>
90+
<div><a href="https://seleniumbase.io/w3schools/checkboxes"><b>W3Schools checkboxes</b></a></div>
8991
<div><a href="https://seleniumbase.io/w3schools/radio_buttons"><b>W3Schools radio buttons</b></a></div>
9092

9193
--------

help_docs/method_summary.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ self.assert_no_js_errors()
396396

397397
self.inspect_html()
398398

399+
self.is_valid_url(url)
400+
399401
self.is_chromium()
400402

401403
self.get_chrome_version()

mkdocs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,16 @@ nav:
128128
- TinyMCE (Test Page): https://seleniumbase.io/tinymce/
129129
- Error Page (Test Page): https://seleniumbase.io/error_page/
130130
- Drag-&-Drop (Test Page): https://seleniumbase.io/other/drag_and_drop
131-
- Virtual Device Farm: https://seleniumbase.io/devices/
131+
- Device Farm (Virtual): https://seleniumbase.io/devices/
132132
- HTML Playground Page: https://seleniumbase.io/w3schools/
133133
- SeleniumBase in iframe: https://seleniumbase.io/w3schools/sbase
134134
- Page with broken links: https://seleniumbase.io/other/broken_page
135+
- Shadow DOM/Root: https://seleniumbase.io/other/shadow_dom
135136
- W3Schools iframes: https://seleniumbase.io/w3schools/iframes
137+
- W3Schools file upload: https://seleniumbase.io/w3schools/file_upload
136138
- W3Schools doubleclick: https://seleniumbase.io/w3schools/double_click
137-
- W3Schools checkboxes: https://seleniumbase.io/w3schools/checkboxes
138139
- W3Schools drag & drop: https://seleniumbase.io/w3schools/drag_drop
140+
- W3Schools checkboxes: https://seleniumbase.io/w3schools/checkboxes
139141
- W3Schools radio buttons: https://seleniumbase.io/w3schools/radio_buttons
140142
- Presentations:
141143
- Presenter Demo: https://seleniumbase.io/other/presenter.html

mkdocs_build/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
regex>=2021.11.10
22
tqdm>=4.62.3
3-
docutils==0.18
3+
docutils==0.18.1
44
python-dateutil==2.8.2
55
livereload==2.6.3;python_version>="3.6"
66
joblib==1.1.0;python_version>="3.6"
77
Markdown==3.3.6;python_version>="3.6"
88
MarkupSafe==2.0.1;python_version>="3.6"
9-
pyparsing==2.4.7;python_version>="3.6"
10-
keyring==23.2.1;python_version>="3.6"
11-
pkginfo==1.7.1;python_version>="3.6"
9+
pyparsing==3.0.6;python_version>="3.6"
10+
keyring==23.3.0;python_version>="3.6"
11+
pkginfo==1.8.1;python_version>="3.6"
1212
Jinja2==3.0.3;python_version>="3.6"
1313
click==8.0.3;python_version>="3.6"
1414
zipp==3.6.0;python_version>="3.6"

requirements.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
pip>=20.3.4;python_version<"3.6"
22
pip>=21.3.1;python_version>="3.6"
33
packaging>=20.9;python_version<"3.6"
4-
packaging>=21.2;python_version>="3.6"
4+
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"
7-
setuptools>=59.1.1;python_version>="3.6"
7+
setuptools>=59.2.0;python_version>="3.6"
88
setuptools-scm>=5.0.2;python_version<"3.6"
99
setuptools-scm>=6.3.2;python_version>="3.6"
1010
tomli>=1.2.2;python_version>="3.6"
@@ -25,7 +25,7 @@ idna==2.10;python_version<"3.6"
2525
idna==3.3;python_version>="3.6"
2626
chardet==3.0.4;python_version<"3.5"
2727
chardet==4.0.0;python_version>="3.5"
28-
charset-normalizer==2.0.7;python_version>="3.5"
28+
charset-normalizer==2.0.8;python_version>="3.5"
2929
urllib3==1.26.7
3030
requests==2.26.0;python_version<"3.5"
3131
requests==2.25.1;python_version>="3.5" and python_version<"3.6"
@@ -37,10 +37,10 @@ trio-websocket==0.9.2;python_version>="3.7"
3737
pyopenssl==21.0.0;python_version>="3.7"
3838
wsproto==1.0.0;python_version>="3.7"
3939
selenium==3.141.0;python_version<"3.7"
40-
selenium==4.0.0;python_version>="3.7"
40+
selenium==4.1.0;python_version>="3.7"
4141
msedge-selenium-tools==3.141.3;python_version<"3.7"
4242
more-itertools==5.0.0;python_version<"3.5"
43-
more-itertools==8.11.0;python_version>="3.5"
43+
more-itertools==8.12.0;python_version>="3.5"
4444
cssselect==1.1.0
4545
sortedcontainers==2.4.0
4646
filelock==3.2.1;python_version<"3.6"
@@ -77,7 +77,7 @@ beautifulsoup4==4.10.0;python_version>="3.5"
7777
cryptography==2.9.2;python_version<"3.5"
7878
cryptography==3.2.1;python_version>="3.5" and python_version<"3.6"
7979
cryptography==3.4.8;python_version>="3.6" and python_version<"3.7"
80-
cryptography==35.0.0;python_version>="3.7"
80+
cryptography==36.0.0;python_version>="3.7"
8181
pygments==2.5.2;python_version<"3.5"
8282
pygments==2.10.0;python_version>="3.5"
8383
prompt-toolkit==1.0.18;python_version<"3.5"
@@ -107,7 +107,8 @@ toml==0.10.2
107107
Pillow==6.2.2;python_version<"3.5"
108108
Pillow==7.2.0;python_version>="3.5" and python_version<"3.6"
109109
Pillow==8.4.0;python_version>="3.6"
110-
typing-extensions==3.10.0.2;python_version<"3.8"
110+
typing-extensions==3.10.0.2;python_version<"3.6"
111+
typing-extensions==4.0.0;python_version>="3.6" and python_version<"3.8"
111112
rich==10.14.0;python_version>="3.6" and python_version<"4.0"
112113
tornado==5.1.1;python_version<"3.5"
113114
tornado==6.1;python_version>="3.5"

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.1.9"
2+
__version__ = "2.2.0"

0 commit comments

Comments
 (0)