Skip to content

Commit 7ad83c4

Browse files
authored
Merge pull request #983 from seleniumbase/recorder-mode
Add SeleniumBase "Recorder Mode"
2 parents f1e6622 + 3d34f26 commit 7ad83c4

39 files changed

+1348
-276
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ images_exported
124124
# Cookies
125125
saved_cookies
126126

127+
# Recordings
128+
recordings
129+
127130
# Automated Visual Testing
128131
visual_baseline
129132

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
<br />
3232
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md">📚 API</a> |
3333
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md">📊 Reports</a> |
34-
<a href="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/boilerplates">♻️ Boilerplates</a> |
34+
<a href="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/boilerplates">♻️ Boilerplate</a> |
3535
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md">🔠 Syntaxes</a> |
36-
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/locale_codes.md">🗾 Locales</a> |
37-
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md">🌐 Grid</a> |
38-
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_ide/ReadMe.md">⏺️ Record</a>
36+
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/recorder_mode.md">⏺️ Recorder</a> |
37+
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/locale_codes.md">🗾 Locale</a> |
38+
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md">🌐 Grid</a>
3939
<br />
4040
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/github/workflows/ReadMe.md">🤖 CI</a> |
4141
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/translations.md">🌏 Translate</a> |
@@ -108,7 +108,7 @@ pip install -e . # Editable install
108108

109109
> (When using a virtual env, the Editable install is faster.)
110110
111-
🔵 You can also install ``seleniumbase`` from [pypi](https://pypi.python.org/pypi/seleniumbase):
111+
🔵 You can also install ``seleniumbase`` from [pypi](https://pypi.org/project/seleniumbase/):
112112

113113
```bash
114114
pip install seleniumbase
@@ -379,6 +379,7 @@ The code above will leave your browser window open in case there's a failure. (i
379379
--ad-block # (Block some types of display ads after page loads.)
380380
--block-images # (Block images from loading during tests.)
381381
--verify-delay=SECONDS # (The delay before MasterQA verification checks.)
382+
--recorder # (Enables the Recorder for turning browser actions into code.)
382383
--disable-csp # (Disable the Content Security Policy of websites.)
383384
--disable-ws # (Disable Web Security on Chromium-based browsers.)
384385
--enable-ws # (Enable Web Security on Chromium-based browsers.)

docs/requirements.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ livereload==2.6.3;python_version>="3.6"
44
joblib==1.0.1;python_version>="3.6"
55
Markdown==3.3.4;python_version>="3.6"
66
MarkupSafe==2.0.1;python_version>="3.6"
7+
jsmin==3.0.0;python_version>="3.6"
78
docutils==0.17.1
89
python-dateutil==2.8.2
10+
keyring==23.2.1;python_version>="3.6"
911
pkginfo==1.7.1;python_version>="3.6"
1012
Jinja2==3.0.1;python_version>="3.6"
1113
click==8.0.1;python_version>="3.6"
@@ -15,10 +17,10 @@ pymdown-extensions==8.2;python_version>="3.6"
1517
importlib-metadata==4.8.1;python_version>="3.6"
1618
bleach==4.1.0
1719
lunr==0.6.0;python_version>="3.6"
18-
nltk==3.6.2;python_version>="3.6"
20+
nltk==3.6.3;python_version>="3.6"
1921
watchdog==2.1.5;python_version>="3.6"
2022
mkdocs==1.2.2;python_version>="3.6"
21-
mkdocs-material==7.1.3;python_version>="3.6"
23+
mkdocs-material==7.2.7;python_version>="3.6"
2224
mkdocs-exclude-search==0.5.2;python_version>="3.6"
2325
mkdocs-simple-hooks==0.1.3
2426
mkdocs-material-extensions==1.0.3;python_version>="3.6"

examples/hack_the_planet.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,14 @@ def test_all_your_base_are_belong_to_us(self):
137137
self.highlight("h1", loops=8, scroll=False)
138138

139139
self.open("https://dev.to/top/infinity")
140+
self.click_if_visible('button[aria-label="Close campaign banner"]')
140141
self.set_text_content('nav a[data-text="Feed"]', "ALL")
141-
self.set_text_content('nav a[data-text="Week"]', "YOUR")
142-
self.set_text_content('nav a[data-text="Month"]', "BASE")
143-
self.set_text_content('nav a[data-text="Year"]', "ARE")
144-
self.set_text_content('nav a[data-text="Infinity"]', "BELONG")
145-
self.set_text_content('nav a[data-text="Latest"]', "TO_US")
142+
self.set_text_content('nav a[data-text="Latest"]', "YOUR")
143+
self.set_text_content('nav a[data-text="Top"]', "BASE")
144+
self.set_text_content('nav a[data-text="Week"]', "ARE")
145+
self.set_text_content('nav a[data-text="Month"]', "BELONG")
146+
self.set_text_content('nav a[data-text="Year"]', "TO")
147+
self.set_text_content('nav a[data-text="Infinity"]', "US")
146148
self.set_text_content('aside a[class*="tful"]', aybabtu)
147149
self.set_text_content('aside a[aria-label="Create new account"]', ayb)
148150
self.set_text_content('aside a[aria-label="Log in"]', abtu)
@@ -156,13 +158,13 @@ def test_all_your_base_are_belong_to_us(self):
156158
self.type('input[name="q"]', aybabtu)
157159
self.highlight('input[name="q"]', loops=4, scroll=False)
158160
self.highlight('[aria-label="Primary sidebar"] div div', scroll=False)
159-
self.highlight('nav.crayons-tabs', loops=3, scroll=False)
160161
self.highlight('nav a[data-text="Feed"]', loops=1, scroll=False)
162+
self.highlight('nav a[data-text="Latest"]', loops=1, scroll=False)
163+
self.highlight('nav a[data-text="Top"]', loops=2, scroll=False)
161164
self.highlight('nav a[data-text="Week"]', loops=1, scroll=False)
162-
self.highlight('nav a[data-text="Month"]', loops=2, scroll=False)
165+
self.highlight('nav a[data-text="Month"]', loops=1, scroll=False)
163166
self.highlight('nav a[data-text="Year"]', loops=1, scroll=False)
164-
self.highlight('nav a[data-text="Infinity"]', loops=1, scroll=False)
165-
self.highlight('nav a[data-text="Latest"]', loops=2, scroll=False)
167+
self.highlight('nav a[data-text="Infinity"]', loops=2, scroll=False)
166168
self.highlight('aside[id*="sidebar"] section', loops=5, scroll=False)
167169
self.highlight("div.crayons-story__body", loops=7, scroll=False)
168170

examples/raw_parameter_script.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
sb.with_db_reporting = False
7171
sb.with_s3_logging = False
7272
sb.js_checking_on = False
73+
sb.recorder_mode = False
74+
sb.recorder_ext = False
7375
sb.report_on = False
7476
sb.is_pytest = False
7577
sb.slow_mode = False

examples/setup.cfg

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
[flake8]
2+
exclude=recordings,temp
3+
14
[nosetests]
25
# This is the config file for default values used during nosetest runs
36
# nocapture=1 displays print statements from output. Undo this by using: --nologcapture
47
# logging-level=INFO keeps the logs much cleaner than using DEBUG
58
nocapture=1
6-
logging-level=INFO
9+
logging-level=INFO

examples/test_demo_site.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ def test_demo_site(self):
6060
self.assert_true(self.is_selected("#radioButton2"))
6161

6262
# Verify that clicking a checkbox makes it selected
63+
self.assert_element_not_visible("img#logo")
6364
self.assert_false(self.is_selected("#checkBox1"))
6465
self.click("#checkBox1")
6566
self.assert_true(self.is_selected("#checkBox1"))
67+
self.assert_element("img#logo")
6668

6769
# Verify clicking on multiple elements with one call
6870
self.assert_false(self.is_selected("#checkBox2"))
@@ -82,6 +84,11 @@ def test_demo_site(self):
8284
self.assert_true(self.is_selected(".fBox"))
8385
self.switch_to_default_content()
8486

87+
# Verify Drag and Drop
88+
self.assert_element_not_visible("div#drop2 img#logo")
89+
self.drag_and_drop("img#logo", "div#drop2")
90+
self.assert_element("div#drop2 img#logo")
91+
8592
# Assert link text
8693
self.assert_link_text("seleniumbase.com")
8794
self.assert_link_text("SeleniumBase on GitHub")

examples/test_drag_and_drop.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
"""
2-
Testing Drag & Drop
2+
Testing Drag & Drop on different pages.
33
"""
4-
54
from seleniumbase import BaseCase
65

76

87
class DragAndDropTests(BaseCase):
98
def test_drag_and_drop(self):
9+
self.open("https://seleniumbase.io/other/drag_and_drop")
10+
self.assert_element_not_visible("#div1 img#drag1")
11+
self.drag_and_drop("#drag1", "#div1")
12+
self.assert_element("#div1 img#drag1")
13+
self.sleep(0.8)
14+
15+
def test_w3schools_drag_and_drop(self):
1016
url = "://w3schools.com/html/tryit.asp?filename=tryhtml5_draganddrop"
1117
self.open(url)
1218
self.remove_elements("#tryitLeaderboard")
1319
self.switch_to_frame("iframeResult")
1420
self.assert_element_not_visible("#div1 img#drag1")
1521
self.drag_and_drop("#drag1", "#div1")
1622
self.assert_element("#div1 img#drag1")
17-
self.sleep(1)
23+
self.sleep(0.8)

help_docs/ReadMe.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<a href="https://seleniumbase.io/help_docs/translations/">🌏 Translate</a> |
3030
<a href="https://seleniumbase.io/examples/dialog_boxes/ReadMe/">🛂 DialogBoxes</a>
3131
<br />
32-
<a href="https://seleniumbase.io/seleniumbase/utilities/selenium_ide/ReadMe/">⏺️ Recorder</a> |
32+
<a href="https://seleniumbase.io/help_docs/recorder_mode.md">⏺️ Recorder</a> |
3333
<a href="https://github.com/seleniumbase/SeleniumBase/tree/master/integrations/node_js">🏃 NodeRunner</a>
3434
<br />
3535
<a href="https://seleniumbase.io/examples/presenter/ReadMe/">📰 Presenter</a> |
@@ -75,6 +75,7 @@
7575
<div><a href="https://seleniumbase.io/tinymce/"><b>TinyMCE Demo Page</b></a></div>
7676
<div><a href="https://seleniumbase.io/devices/"><b>Virtual Device Farm</b></a></div>
7777
<div><a href="https://seleniumbase.io/error_page/"><b>Error Page for Tests</b></a></div>
78+
<div><a href="https://seleniumbase.io/other/drag_and_drop"><b>Drag-&-Drop Test Page</b></a></div>
7879
<div><a href="https://seleniumbase.io/other/presenter.html"><b>Presenter Demo</b></a></div>
7980
<div><a href="https://seleniumbase.io/other/core_presentation.html"><b>Core Presentation</b></a></div>
8081
<div><a href="https://seleniumbase.io/other/chart_presentation.html"><b>Chart Maker Demo</b></a></div>

help_docs/customizing_test_runs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ SeleniumBase provides additional ``pytest`` command-line options for tests:
140140
--ad-block # (Block some types of display ads after page loads.)
141141
--block-images # (Block images from loading during tests.)
142142
--verify-delay=SECONDS # (The delay before MasterQA verification checks.)
143+
--recorder # (Enables the Recorder for turning browser actions into code.)
143144
--disable-csp # (Disable the Content Security Policy of websites.)
144145
--disable-ws # (Disable Web Security on Chromium-based browsers.)
145146
--enable-ws # (Enable Web Security on Chromium-based browsers.)

0 commit comments

Comments
 (0)