|
57 | 57 |
|
58 | 58 | -------- |
59 | 59 |
|
60 | | -<p align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/sb_logo_p3.png" alt="SeleniumBase" title="SeleniumBase" width="232" /></a></p> |
| 60 | +<p align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/super_logo_sb2.png" alt="SeleniumBase" title="SeleniumBase" width="232" /></a></p> |
61 | 61 |
|
62 | 62 | <blockquote> |
63 | 63 | <p dir="auto"><strong>Explore the README:</strong></p> |
@@ -439,6 +439,7 @@ self.sleep(seconds) # Do nothing for the given amount of time. |
439 | 439 | self.save_screenshot(name) # Save a screenshot in .png format. |
440 | 440 | self.assert_element(selector) # Verify the element is visible. |
441 | 441 | self.assert_text(text, selector) # Verify text in the element. |
| 442 | +self.assert_exact_text(text, selector) # Verify text is exact. |
442 | 443 | self.assert_title(title) # Verify the title of the web page. |
443 | 444 | self.assert_downloaded_file(file) # Verify file was downloaded. |
444 | 445 | self.assert_no_404_errors() # Verify there are no broken links. |
@@ -485,10 +486,10 @@ behave calculator.feature -D rs -D dashboard |
485 | 486 |
|
486 | 487 | With a SeleniumBase [pytest.ini](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/pytest.ini) file present, you can modify default discovery settings. The Python class name can be anything because ``seleniumbase.BaseCase`` inherits ``unittest.TestCase`` to trigger autodiscovery. |
487 | 488 |
|
488 | | -<p>✅ You can do a pre-flight check to see which tests would get discovered by <code translate="no">pytest</code> before the real flight:</p> |
| 489 | +<p>✅ You can do a pre-flight check to see which tests would get discovered by <code translate="no">pytest</code> before the actual run:</p> |
489 | 490 |
|
490 | 491 | ```bash |
491 | | -pytest --collect-only -q |
| 492 | +pytest --co -q |
492 | 493 | ``` |
493 | 494 |
|
494 | 495 | <p>✅ You can be more specific when calling <code translate="no">pytest</code> or <code translate="no">pynose</code> on a file:</p> |
@@ -567,7 +568,8 @@ pytest test_coffee_cart.py --trace |
567 | 568 | -q # Quiet mode. Print fewer details in the console output when running tests. |
568 | 569 | -x # Stop running the tests after the first failure is reached. |
569 | 570 | --html=report.html # Creates a detailed pytest-html report after tests finish. |
570 | | ---collect-only | --co # Show what tests would get run. (Without running them) |
| 571 | +--co | --collect-only # Show what tests would get run. (Without running them) |
| 572 | +--co -q # (Both options together!) - Do a dry run with full test names shown. |
571 | 573 | -n=NUM # Multithread the tests using that many threads. (Speed up test runs!) |
572 | 574 | -s # See print statements. (Should be on by default with pytest.ini present.) |
573 | 575 | --junit-xml=report.xml # Creates a junit-xml report after tests finish. |
@@ -656,6 +658,7 @@ pytest test_coffee_cart.py --trace |
656 | 658 | --swiftshader # (Use Chrome's "--use-gl=swiftshader" feature.) |
657 | 659 | --incognito # (Enable Chrome's Incognito mode.) |
658 | 660 | --guest # (Enable Chrome's Guest mode.) |
| 661 | +--dark # (Enable Chrome's Dark mode.) |
659 | 662 | --devtools # (Open Chrome's DevTools when the browser opens.) |
660 | 663 | --rs | --reuse-session # (Reuse browser session for all tests.) |
661 | 664 | --rcs | --reuse-class-session # (Reuse session for tests in class.) |
@@ -1157,22 +1160,39 @@ self.switch_to_window(1) # This switches to the new tab (0 is the first one) |
1157 | 1160 |
|
1158 | 1161 | <h3>🔵 How to handle iframes:</h3> |
1159 | 1162 |
|
1160 | | -🔵 <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: |
| 1163 | +🔵 <b>iframes</b> follow the same principle as new windows: You must first switch to the iframe if you want to perform actions in there: |
1161 | 1164 |
|
1162 | 1165 | ```python |
1163 | 1166 | self.switch_to_frame("iframe") |
1164 | 1167 | # ... Now perform actions inside the iframe |
1165 | 1168 | self.switch_to_parent_frame() # Exit the current iframe |
1166 | 1169 | ``` |
1167 | 1170 |
|
1168 | | -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()``. |
| 1171 | +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()``.) |
| 1172 | +
|
| 1173 | +```python |
| 1174 | +self.switch_to_frame('iframe[name="frame1"]') |
| 1175 | +self.switch_to_frame('iframe[name="frame2"]') |
| 1176 | +# ... Now perform actions inside the inner iframe |
| 1177 | +self.switch_to_default_content() # Back to the main page |
| 1178 | +``` |
1169 | 1179 |
|
1170 | 1180 | 🔵 You can also use a context manager to act inside iframes: |
1171 | 1181 |
|
1172 | 1182 | ```python |
1173 | 1183 | with self.frame_switch("iframe"): |
1174 | 1184 | # ... Now perform actions while inside the code block |
1175 | | -# You have left the iframe! |
| 1185 | +# You have left the iframe |
| 1186 | +``` |
| 1187 | +
|
| 1188 | +This also works with nested iframes: |
| 1189 | +
|
| 1190 | +```python |
| 1191 | +with self.frame_switch('iframe[name="frame1"]'): |
| 1192 | + with self.frame_switch('iframe[name="frame2"]'): |
| 1193 | + # ... Now perform actions while inside the code block |
| 1194 | + # You are now back inside the first iframe |
| 1195 | +# You have left all the iframes |
1176 | 1196 | ``` |
1177 | 1197 |
|
1178 | 1198 | <h3>🔵 How to execute custom jQuery scripts:</h3> |
|
0 commit comments