Skip to content

Commit bea532f

Browse files
authored
Merge pull request #999 from seleniumbase/recorder-upgrade
Upgrade Recorder Mode, and more
2 parents 63fdb24 + f775245 commit bea532f

File tree

12 files changed

+226
-74
lines changed

12 files changed

+226
-74
lines changed

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ docutils==0.17.1
99
python-dateutil==2.8.2
1010
keyring==23.2.1;python_version>="3.6"
1111
pkginfo==1.7.1;python_version>="3.6"
12-
Jinja2==3.0.1;python_version>="3.6"
12+
Jinja2==3.0.2;python_version>="3.6"
1313
click==8.0.1;python_version>="3.6"
1414
zipp==3.6.0;python_version>="3.6"
1515
readme-renderer==30.0

examples/parameterized_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from seleniumbase import BaseCase
21
from parameterized import parameterized
2+
from seleniumbase import BaseCase
33

44

55
class GoogleTests(BaseCase):

examples/test_hack_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ def test_hack_search(self):
2121
self.highlight_click(help_docs_install_link)
2222
self.assert_text("Install SeleniumBase", "h1")
2323
self.click_link_text("GitHub branch")
24-
self.highlight_click('a[href*="github.com/seleniumbase/SeleniumBase"]')
24+
self.highlight_click('a[href*="/seleniumbase/SeleniumBase"]')
2525
self.assert_element('[href="/seleniumbase/SeleniumBase"]')
2626
self.assert_true("seleniumbase/SeleniumBase" in self.get_current_url())
27-
self.click('a[title="examples"]')
27+
self.highlight_click('a[title="examples"]')
2828
self.assert_text("examples", "strong.final-path")
2929
self.highlight_click('[title="test_hack_search.py"]')
3030
self.assert_text("test_hack_search.py", "strong.final-path")

examples/test_skype_site.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Usage: pytest test_skype_site.py --mobile --browser=edge
44
55
Default mobile settings for User Agent and Device Metrics if not specified:
6-
User Agent: --agent="Mozilla/5.0 (Linux; Android 9; Pixel 3 XL)"
6+
User Agent: --agent="Mozilla/5.0 (Linux; Android 11; Pixel 4 XL)"
77
CSS Width, CSS Height, Pixel-Ratio: --metrics="411,731,3"
88
"""
99
from seleniumbase import BaseCase
@@ -16,8 +16,6 @@ def test_skype_mobile_site(self):
1616
print(' (Use "--mobile" to run this test in Mobile Mode!)')
1717
self.skip('Use "--mobile" to run this test in Mobile Mode!')
1818
self.open("https://www.skype.com/en/")
19-
self.assert_text("Install Skype", "div.appInfo")
20-
self.highlight("div.appBannerContent")
2119
self.highlight('[itemprop="url"]')
2220
self.highlight("h1")
2321
self.highlight('[data-bi-area="meet-now-home-page"]')

examples/test_todomvc.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from parameterized import parameterized
2+
from seleniumbase import BaseCase
3+
4+
5+
class TodoMVC(BaseCase):
6+
@parameterized.expand(
7+
[
8+
["angularjs"],
9+
["mithril"],
10+
["react"],
11+
["vue"],
12+
]
13+
)
14+
def test_todomvc(self, framework):
15+
self.open("https://todomvc.com/")
16+
self.clear_local_storage()
17+
self.click('a[href="examples/%s"]' % framework)
18+
self.assert_element("section.todoapp")
19+
new_todo_input = "input.new-todo"
20+
todo_count_span = "span.todo-count"
21+
self.type(new_todo_input, "Learn Python\n")
22+
self.type(new_todo_input, "Learn JavaScript\n")
23+
self.type(new_todo_input, "Learn SeleniumBase\n")
24+
self.assert_text("3 items left", todo_count_span)
25+
self.check_if_unchecked("ul.todo-list li input")
26+
self.check_if_unchecked("ul.todo-list li:nth-of-type(2) input")
27+
self.check_if_unchecked("ul.todo-list li:nth-of-type(3) input")
28+
self.assert_text("0 items left", todo_count_span)
29+
self.click('label[for="toggle-all"]')
30+
self.assert_text("3 items left", todo_count_span)

help_docs/recorder_mode.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
<img src="https://seleniumbase.io/cdn/img/sb_recorder_notification.png" title="SeleniumBase" width="380">
88

9-
🔴 To activate Recorder Mode, add ``--recorder`` to your ``pytest`` run command when running an existing test on Chrome or Edge. (Also add ``-s`` to allow breakpoints, unless you already have a ``pytest.ini`` file present with ``addopts = --capture=no`` in it.)
9+
🔴 To activate Recorder Mode, add ``--rec`` OR ``--record`` OR ``--recorder`` to your ``pytest`` run command when running an existing test on Chrome or Edge. (Also add ``-s`` to allow breakpoints, unless you already have a ``pytest.ini`` file present with ``addopts = --capture=no`` in it.)
1010

1111
```bash
12-
pytest TEST_NAME.py --recorder -s
12+
pytest TEST_NAME.py --rec -s
1313
```
1414

1515
🔴 To add manual actions, you'll need to create a breakpoint inside your test to activate "Debug Mode" while in "Recorder Mode": (For reference, "Debug Mode" is also known as the "ipdb debugger".)
@@ -23,7 +23,7 @@ import ipdb; ipdb.set_trace()
2323
🔴 You can also activate Debug Mode at the start of your test by adding ``--trace`` as a ``pytest`` command-line option:
2424

2525
```bash
26-
pytest TEST_NAME.py --trace --recorder -s
26+
pytest TEST_NAME.py --trace --rec -s
2727
```
2828

2929
🔴 Once you've reached the breakpoint, you can take control of the browser and add in any actions that you want recorded. When you are finished recording, type "``c``" on the command-line and press ``[Enter]`` to let the test continue from the breakpoint. After the test completes, a file called ``TEST_NAME_rec.py`` will be automatically created in the ``./recordings`` folder, which will include the actions performed by the test, and the manual actions that you added in. Below is a command-line notification:
@@ -42,7 +42,7 @@ pytest TEST_NAME.py --trace --recorder -s
4242

4343
🔴 While a recording is in progress, you can hit the ``[ESC]`` key to pause the recording. To resume the recording, you can hit the ``[~`]`` key, which is located directly below the ``[ESC]`` key on most keyboards.
4444

45-
<p>🔴 If you want to create a recording from scratch, just run:<br><code>pytest --recorder</code> on a Python file such as this one:</p>
45+
<p>🔴 If you want to create a recording from scratch, just run:<br><code>pytest --rec</code> on a Python file such as this one:</p>
4646

4747
```python
4848
from seleniumbase import BaseCase
@@ -56,7 +56,7 @@ class RecorderTest(BaseCase):
5656

5757
<p>🔴 Recorder Mode works by saving your recorded actions into the browser's <code>sessionStorage</code>. SeleniumBase then reads from the browser's <code>sessionStorage</code> to take the raw data and generate a full test from it. Keep in mind that <code>sessionStorage</code> is only present for a website while the browser tab remains on a web page of the same domain/origin. If you leave that domain/origin, the <code>sessionStorage</code> of that tab will no longer have the raw data that SeleniumBase needs to create a full recording. To compensate for this, all links to web pages of a different domain/origin will automatically open a new tab for you while in Recorder Mode. Additionally, the SeleniumBase <code>self.open(URL)</code> method will also open a new tab for you in Recorder Mode if the domain/origin is different from the current URL. When the recorded test completes, SeleniumBase will scan the <code>sessionStorage</code> of all open browser tabs for the data it needs to generate the complete SeleniumBase automation script.</p>
5858

59-
<p>🔴 If you just want to record actions on a single URL of a multi-URL test, you can call <code>self.activate_recorder()</code> from the test instead of using <code>pytest --recorder</code> from the command-line. When doing so, make sure that the browser tab is still on the same domain/origin at the end of the test, or else SeleniumBase will not have access to the <code>sessionStorage</code> data that it needs for generating a complete test.</p>
59+
<p>🔴 If you just want to record actions on a single URL of a multi-URL test, you can call <code>self.activate_recorder()</code> from within the test instead of using <code>pytest --rec</code> from the command-line. When doing so, make sure that the browser tab is still on the same domain/origin at the end of the test, or else SeleniumBase will not have access to the <code>sessionStorage</code> data that it needs for generating a complete test.</p>
6060

6161
<p>🔴 (Note that <b>same domain/origin</b> is not the same as <b>same URL</b>. Example: <code>https://xkcd.com/353/</code> and <code>https://xkcd.com/1537/</code> are two different URLs with the <b>same domain/origin</b>. That means that both URLs will share the same <code>sessionStorage</code> data, and that any changes to <code>sessionStorage</code> from one URL will carry on to the <code>sessionStorage</code> of a different URL when the domain/origin is the same. If you want to find out a website's origin during a test, just call: <code>self.get_origin()</code>, which returns the value of <code>window.location.origin</code> from the browser's console.)</p>
6262

@@ -72,10 +72,12 @@ class RecorderTest(BaseCase):
7272

7373
<p>🔴 SeleniumBase <code>1.66.5</code> improves the algorithm for converting recorded actions into SeleniumBase code.</p>
7474

75-
<p>🔴 SeleniumBase <code>1.66.6</code> adds more selector options and improves the algorithm for converting recorded actions into SeleniumBase code.</p>
75+
<p>🔴 SeleniumBase <code>1.66.6</code> improves the algorithm for converting recorded actions into SeleniumBase code.</p>
7676

7777
<p>🔴 SeleniumBase <code>1.66.7</code> improves Recorder Mode post-processing and automatically adds <code>self.show_file_choosers()</code> if file-upload fields are hidden when calling <code>self.choose_file(selector, file_path)</code>.</p>
7878

79+
<p>🔴 SeleniumBase <code>1.66.8</code> generates better selectors in Recorder Mode and improves the algorithm for converting recorded actions into SeleniumBase code.</p>
80+
7981
--------
8082

8183
<div>To learn more about SeleniumBase, check out the Docs Site:</div>

requirements.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ beautifulsoup4==4.9.3;python_version<"3.5"
6969
beautifulsoup4==4.10.0;python_version>="3.5"
7070
cryptography==2.9.2;python_version<"3.5"
7171
cryptography==3.2.1;python_version>="3.5" and python_version<"3.6"
72-
cryptography==3.4.8;python_version>="3.6"
72+
cryptography==3.4.8;python_version>="3.6" and python_version<"3.7"
73+
cryptography==35.0.0;python_version>="3.7"
7374
pygments==2.5.2;python_version<"3.5"
7475
pygments==2.10.0;python_version>="3.5"
7576
traitlets==4.3.3;python_version<"3.7"
@@ -111,7 +112,8 @@ pdfminer.six==20201018;python_version>="3.5"
111112

112113
coverage==5.5;python_version<"3.6"
113114
coverage==6.0;python_version>="3.6"
114-
pytest-cov==2.12.1
115+
pytest-cov==2.12.1;python_version<"3.6"
116+
pytest-cov==3.0.0;python_version>="3.6"
115117
flake8==3.7.9;python_version<"3.5"
116118
flake8==3.9.2;python_version>="3.5"
117119
pyflakes==2.1.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__ = "1.66.7"
2+
__version__ = "1.66.8"

seleniumbase/extensions/recorder.zip

358 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)