Skip to content

Commit 893d50a

Browse files
committed
Update the ReadMe
1 parent 92039e3 commit 893d50a

File tree

1 file changed

+51
-18
lines changed

1 file changed

+51
-18
lines changed

README.md

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ with SB() as sb: # By default, browser="chrome" if not set.
217217
sb.assert_exact_text("You have been signed out!", "#top_message")
218218
```
219219

220-
<p align="left">📕📝 An example test with <b>behave-BDD</b> <a href="https://behave.readthedocs.io/en/stable/gherkin.html" target="_blank">Gherkin</a> structure. Runs with <b><code>behave</code></b>. (<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md">Learn more</a>)</p>
220+
<p align="left">📕📝 An example test with <b>behave-BDD</b> <a href="https://behave.readthedocs.io/en/stable/gherkin.html#features" target="_blank">Gherkin</a> structure. Runs with <b><code>behave</code></b>. (<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md">Learn more</a>)</p>
221221

222222
```gherkin
223223
Feature: SeleniumBase scenarios for the RealWorld App
@@ -252,7 +252,7 @@ Feature: SeleniumBase scenarios for the RealWorld App
252252

253253
**You can install ``seleniumbase`` from [PyPI](https://pypi.org/project/seleniumbase/) or [GitHub](https://github.com/seleniumbase/SeleniumBase):**
254254

255-
🔵 **Installing ``seleniumbase`` from PyPI:**
255+
🔵 **How to install ``seleniumbase`` from PyPI:**
256256

257257
```bash
258258
pip install seleniumbase
@@ -262,22 +262,22 @@ pip install seleniumbase
262262
* (Add ``--force-reinstall`` to upgrade indirect packages.)
263263
* (Use ``pip3`` if multiple versions of Python are present.)
264264

265-
🔵 **Installing ``seleniumbase`` from a GitHub clone:**
265+
🔵 **How to install ``seleniumbase`` from a GitHub clone:**
266266

267267
```bash
268268
git clone https://github.com/seleniumbase/SeleniumBase.git
269269
cd SeleniumBase/
270270
pip install -e .
271271
```
272272

273-
**To upgrade an existing install from a GitHub clone:**
273+
🔵 **How to upgrade an existing install from a GitHub clone:**
274274

275275
```bash
276276
git pull
277277
pip install -e .
278278
```
279279

280-
🔵 Type ``seleniumbase`` or ``sbase`` to verify that SeleniumBase was installed successfully:
280+
🔵 **Type ``seleniumbase`` or ``sbase`` to verify that SeleniumBase was installed successfully:**
281281

282282
```bash
283283
______ __ _ ____
@@ -324,11 +324,33 @@ COMMANDS:
324324
Use "pytest" for running tests.
325325
```
326326
327-
328-
<h3>🔵 Downloading webdrivers:</h3>
327+
🔵 **Downloading webdrivers:**
329328
330329
✅ SeleniumBase automatically downloads webdrivers as needed, such as ``chromedriver``.
331330
331+
<div></div>
332+
<details>
333+
<summary> ▶️ Here's output from a download. (<b>click to expand</b>)</summary>
334+
335+
```bash
336+
*** chromedriver version for download = 114.0.5735.90 (Latest)
337+
338+
Downloading chromedriver_mac_arm64.zip from:
339+
https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_mac_arm64.zip ...
340+
Download Complete!
341+
342+
Extracting ['chromedriver'] from chromedriver_mac_arm64.zip ...
343+
Unzip Complete!
344+
345+
The file [chromedriver] was saved to:
346+
/Users/michael/github/SeleniumBase/seleniumbase/drivers/chromedriver
347+
348+
Making [chromedriver 114.0.5735.90] executable ...
349+
[chromedriver 114.0.5735.90] is now ready for use!
350+
```
351+
352+
</details>
353+
332354
✅ To manually download a webdriver, see [Console Scripts](https://seleniumbase.io/seleniumbase/console_scripts/ReadMe/) OR [Webdriver Installation](https://seleniumbase.io/help_docs/webdriver_installation/).
333355
334356
@@ -441,7 +463,7 @@ self.assert_no_js_errors() # Verify there are no JS errors.
441463
self.type("input", "dogs\n")
442464
```
443465
444-
Most SeleniumBase scripts can be run with <code>pytest</code>, <code>pynose</code>, or pure <code>python</code>. Not all test runners can run all test formats. For example, tests that use the ``sb`` pytest fixture can only be run with ``pytest``. (See <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md">Syntax Formats</a>) There's also a <a href="https://behave.readthedocs.io/en/stable/gherkin.html" target="_blank">Gherkin</a> test format that runs with <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md">behave</a>.
466+
Most SeleniumBase scripts can be run with <code>pytest</code>, <code>pynose</code>, or pure <code>python</code>. Not all test runners can run all test formats. For example, tests that use the ``sb`` pytest fixture can only be run with ``pytest``. (See <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md">Syntax Formats</a>) There's also a <a href="https://behave.readthedocs.io/en/stable/gherkin.html#features" target="_blank">Gherkin</a> test format that runs with <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md">behave</a>.
445467
446468
```bash
447469
pytest test_sb_fixture.py
@@ -1120,16 +1142,27 @@ if self.is_link_text_visible("Stop! Hammer time!"):
11201142
self.switch_to_window(1) # This switches to the new tab (0 is the first one)
11211143
```
11221144
1123-
🔵 <b>ProTip™:</b> iframes follow the same principle as new windows - you need to specify the iframe if you want to take action on something in there
1145+
<h3>🔵 How to handle iframes:</h3>
1146+
1147+
🔵 <b>ProTip™:</b> iframes follow the same principle as new windows: You must first switch to the iframe if you want to perform actions in there:
1148+
1149+
```python
1150+
self.switch_to_frame("iframe")
1151+
# ... Now perform actions inside the iframe
1152+
self.switch_to_parent_frame() # Exit the current iframe
1153+
```
1154+
1155+
To exit from multiple iframes, use ``self.switch_to_default_content()``. If inside a single iframe, this has the same effect as ``self.switch_to_parent_frame()``.
1156+
1157+
🔵 You can also use a context manager to act inside iframes:
11241158
11251159
```python
1126-
self.switch_to_frame('ContentManagerTextBody_ifr')
1127-
# Now you can act inside the iframe
1128-
# .... Do something cool (here)
1129-
self.switch_to_default_content() # Exit the iframe when you're done
1160+
with self.frame_switch("iframe"):
1161+
# ... Now perform actions while inside the code block
1162+
# You have left the iframe!
11301163
```
11311164
1132-
<h3>🔵 Executing Custom jQuery Scripts:</h3>
1165+
<h3>🔵 How to execute custom jQuery scripts:</h3>
11331166
11341167
<p>jQuery is a powerful JavaScript library that allows you to perform advanced actions in a web browser.
11351168
If the web page you're on already has jQuery loaded, you can start executing jQuery scripts immediately.
@@ -1173,7 +1206,7 @@ self.execute_script("return jQuery('textarea')[2].value") # Returns the css "va
11731206
11741207
</details>
11751208
1176-
<h3>🔵 Handling a restrictive CSP:</h3>
1209+
<h3>🔵 How to handle a restrictive CSP:</h3>
11771210
11781211
🛑 Some websites have a restrictive [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) to prevent users from loading jQuery and other external libraries onto their websites. If you need to use jQuery or another JS library on such a website, add ``--disable-csp`` as a ``pytest`` command-line option.
11791212
@@ -1196,7 +1229,7 @@ self.click("a.analytics") # Clicks the generated button
11961229
11971230
</details>
11981231
1199-
<h3>🔵 Using deferred asserts:</h3>
1232+
<h3>🔵 How to use deferred asserts:</h3>
12001233
12011234
<p>Let's say you want to verify multiple different elements on a web page in a single test, but you don't want the test to fail until you verified several elements at once so that you don't have to rerun the test to find more missing elements on the same page. That's where deferred asserts come in. Here's the example:</p>
12021235
@@ -1220,7 +1253,7 @@ class MyTestClass(BaseCase):
12201253
<code>deferred_assert_element()</code> and <code>deferred_assert_text()</code> will save any exceptions that would be raised.
12211254
To flush out all the failed deferred asserts into a single exception, make sure to call <code>self.process_deferred_asserts()</code> at the end of your test method. If your test hits multiple pages, you can call <code>self.process_deferred_asserts()</code> before navigating to a new page so that the screenshot from your log files matches the URL where the deferred asserts were made.
12221255
1223-
<h3>🔵 Accessing Raw <a href="https://www.selenium.dev/documentation/webdriver/" target="_blank">WebDriver</a>:</h3>
1256+
<h3>🔵 How to access raw <a href="https://www.selenium.dev/documentation/webdriver/" target="_blank">WebDriver</a>:</h3>
12241257
12251258
<p>If you need access to any commands that come with standard <a href="https://www.selenium.dev/documentation/webdriver/" target="_blank">WebDriver</a>, you can call them directly like this:</p>
12261259
@@ -1234,7 +1267,7 @@ self.driver.find_elements("partial link text", "GitHub")
12341267
12351268
<h3>🔵 How to retry failing tests automatically:</h3>
12361269
1237-
<p>You can use <code>--reruns=NUM</code> to retry failing tests that many times. Use <code>--reruns-delay=SECONDS</code> to wait that many seconds between retries. Example:</p>
1270+
<p>You can use <code>pytest --reruns=NUM</code> to retry failing tests that many times. Add <code>--reruns-delay=SECONDS</code> to wait that many seconds between retries. Example:</p>
12381271
12391272
```bash
12401273
pytest --reruns=1 --reruns-delay=1

0 commit comments

Comments
 (0)