Skip to content

Commit 5714cb9

Browse files
authored
Merge pull request #990 from seleniumbase/recorder-mode-optimizations
Recorder Mode optimizations
2 parents 601d298 + 5a76167 commit 5714cb9

File tree

11 files changed

+162
-109
lines changed

11 files changed

+162
-109
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
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/examples/presenter/ReadMe.md">🎞️ Slides</a> |
42-
<a href="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/boilerplates">♻️ Boilerplates</a> |
4342
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/translations.md">🌏 Translate</a> |
43+
<a href="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/boilerplates">♻️ Boilerplates</a> |
4444
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md">🗺️ Tour</a> |
4545
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/chart_maker/ReadMe.md">📶 Charts</a> |
4646
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/dialog_boxes/ReadMe.md">🛂 DialogBox</a>

examples/test_hack_search.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ def test_hack_search(self):
1616
self.sleep(0.5)
1717
self.js_click('[value="Bing Search"]')
1818
self.highlight("h1.b_logo")
19+
help_docs_install_link = 'a[href*="seleniumbase.io/help_docs/install"]'
20+
if self.is_element_visible(help_docs_install_link):
21+
self.highlight_click(help_docs_install_link)
22+
self.switch_to_newest_window()
23+
self.assert_text("Install SeleniumBase", "h1")
24+
self.click_link_text("GitHub branch")
1925
self.highlight_click('a[href*="github.com/seleniumbase/SeleniumBase"]')
2026
self.switch_to_newest_window()
2127
self.assert_element('[href="/seleniumbase/SeleniumBase"]')

help_docs/install.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/README.md"><img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" alt="SeleniumBase" title="SeleniumBase" width="360" /></a>
1+
[<img src="https://seleniumbase.io/cdn/img/sb_logo_10t.png" title="SeleniumBase" width="220">](https://github.com/seleniumbase/SeleniumBase/)
22

33
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Installation</h2>
44

@@ -37,3 +37,7 @@ pip install git+https://github.com/seleniumbase/SeleniumBase.git@master#egg=sele
3737
> (Use ``pip3`` if multiple versions of Python are installed.)
3838
3939
(If you're not using a virtual environment, you may need to add <code>--user</code> to your <code>pip</code> command if you're seeing errors during installation.)
40+
41+
--------
42+
43+
<a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" alt="SeleniumBase" title="SeleniumBase" width="280" /></a>

help_docs/recorder_mode.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class RecorderTest(BaseCase):
5858

5959
<p>🔴 SeleniumBase <code>1.66.2</code> adds the ability to save selectors using the <code>":contains(TEXT)"</code> selector. If a Python file being recorded has multiple tests being run, then all those tests will get saved to the generated <code>*_rec.py</code> file. The Recorder will now save common <code>self.assert_*</code> calls made during tests. In order to escape iframes when using <code>self.set_content_to_frame(frame)</code>, a new method was added: <code>self.set_content_to_default()</code>. The <code>self.set_content_to_*()</code> methods will be automatically used in place of <code>self.switch_to_*()</code> methods in Recorder Mode, unless a test explicitly calls <code>self._rec_overrides_switch = False</code> before the <code>self.switch_to_*()</code> methods are called. Additionally, if an iframe contains the <code>src</code> attribute, that page will get loaded in a new tab when switching to it in Recorder Mode.</p>
6060

61+
<p>🔴 SeleniumBase <code>1.66.3</code> improves the algorithm for generating efficient selectors. Additionally, single and double quotes in selectors will now be properly escaped with backslashes as needed.</p>
62+
6163
--------
6264

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

help_docs/syntax_formats.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h3 align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/mac_sb_logo_3.png" title="SeleniumBase" width="360" /></a></h3>
1+
<h3 align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/mac_sb_logo_3.png" title="SeleniumBase" width="320" /></a></h3>
22

33
<a id="syntax_formats"></a>
44
<h2><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> The 17 syntax formats</h2>
@@ -194,21 +194,22 @@ from seleniumbase.translate.chinese import 硒测试用例
194194

195195
class 我的测试类(硒测试用例):
196196
def test_例子1(self):
197-
self.开启网址("https://xkcd.in/comic?lg=cn&id=353")
198-
self.断言标题("Python - XKCD中文站")
199-
self.断言元素("#content div.comic-body")
200-
self.断言文本("上漫画")
201-
self.单击("div.nextLink")
202-
self.断言文本("母亲的功绩", "#content h1")
203-
self.单击链接文本("下一篇")
204-
self.断言文本("敲打", "#content h1")
205-
self.断言文本("有时,最有趣的事也会显得无聊")
206-
self.回去()
207-
self.单击链接文本("兰德尔·门罗")
208-
self.断言文本("兰德尔·门罗", "#firstHeading")
209-
self.输入文本("#searchInput", "程式设计")
197+
self.开启("https://zh.wikipedia.org/wiki/")
198+
self.断言标题("维基百科,自由的百科全书")
199+
self.断言元素('a[title="首页"]')
200+
self.断言文本("新闻动态", "span#新闻动态")
201+
self.输入文本("#searchInput", "舞龍")
210202
self.单击("#searchButton")
211-
self.断言文本("程序设计", "#firstHeading")
203+
self.断言文本("舞龍", "#firstHeading")
204+
self.断言元素('img[src*="Chinese_draak.jpg"]')
205+
self.输入文本("#searchInput", "火鍋")
206+
self.单击("#searchButton")
207+
self.断言文本("火鍋", "#firstHeading")
208+
self.断言元素('td:contains("火鍋的各種食材")')
209+
self.输入文本("#searchInput", "精武英雄")
210+
self.单击("#searchButton")
211+
self.断言元素('img[src*="Fist_of_legend.jpg"]')
212+
self.断言文本("李连杰", 'li a[title="李连杰"]')
212213
```
213214

214215
(See <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/translations/chinese_test_1.py">examples/translations/chinese_test_1.py</a> for the Chinese test.)

help_docs/translations.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h3 align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/super_logo_m.png" title="SeleniumBase" width="300" /></a></h3>
1+
<h3 align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/mac_sb_logo_3.png" title="SeleniumBase" width="300" /></a></h3>
22

33
<a id="language_tests"></a>
44
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Language Tests (Python 3+)</h3>
@@ -7,15 +7,26 @@
77

88
Examples can be found in [<a href="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/translations">SeleniumBase/examples/translations</a>].
99

10-
Multi-language tests are run with **pytest** like any other test. Every test method has a one-to-one mapping to every other supported language. <i>Example:</i>
11-
```
12-
self.open(URL) <=> self.开启网址(URL)
10+
Multi-language tests are run with **pytest** like any other test. Test methods have a one-to-one mapping to the other supported languages. Here's an example of a translated test:
11+
12+
```python
13+
from seleniumbase.translate.chinese import 硒测试用例
14+
15+
class 我的测试类(硒测试用例):
16+
def test_例子1(self):
17+
self.开启("https://zh.wikipedia.org/wiki/")
18+
self.断言标题("维基百科,自由的百科全书")
19+
self.断言元素('a[title="首页"]')
20+
self.断言文本("新闻动态", "span#新闻动态")
21+
self.输入文本("#searchInput", "舞龍")
22+
self.单击("#searchButton")
23+
self.断言文本("舞龍", "#firstHeading")
1324
```
1425

1526
<a id="translation_api"></a>
1627
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Translation API</h2>
1728

18-
You can use SeleniumBase to selectively translate the method names of any test from one language to another via the console scripts interface. Additionally, the ``import`` line at the top of the Python file will change to import the new ``BaseCase``. Example: ``BaseCase`` becomes ``CasoDeTeste`` when a test is translated into Portuguese.
29+
You can use SeleniumBase to selectively translate the method names of any test from one language to another with the console scripts interface. Additionally, the ``import`` line at the top of the Python file will change to import the new ``BaseCase``. Example: ``BaseCase`` becomes ``CasoDeTeste`` when a test is translated into Portuguese.
1930

2031
```bash
2132
seleniumbase translate
@@ -59,3 +70,7 @@ plus the 2-letter language code of the new language.
5970
(Example: Translating ``test_1.py`` into Japanese with
6071
``-c`` will create a new file called ``test_1_ja.py``.)
6172
```
73+
74+
--------
75+
76+
<h3 align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/super_logo_m.png" title="SeleniumBase" width="280" /></a></h3>

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ extra:
142142
analytics:
143143
provider: google
144144
property: UA-167313767-1
145-
google_analytics: ['UA-167313767-1', 'seleniumbase.io']
145+
# google_analytics: ['UA-167313767-1', 'seleniumbase.io']

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

seleniumbase/extensions/recorder.zip

276 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)