Skip to content

Commit da9dfe3

Browse files
committed
Update documentation
1 parent 1321343 commit da9dfe3

File tree

2 files changed

+44
-31
lines changed

2 files changed

+44
-31
lines changed

help_docs/syntax_formats.md

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
<a id="syntax_formats"></a>
44

5-
## [<img src="https://seleniumbase.github.io/img/logo6.png" title="SeleniumBase" width="40">](https://github.com/seleniumbase/SeleniumBase/) The 23 Syntax Formats / Design Patterns
5+
<h2><img src="https://seleniumbase.github.io/img/logo6.png" title="SeleniumBase" width="40"> The 23 Syntax Formats / Design Patterns</h2>
66

7-
<h3>SeleniumBase supports multiple ways of structuring tests:</h3>
7+
<h3>🔡 SeleniumBase supports multiple ways of structuring tests:</h3>
88

99
<blockquote>
1010
<p dir="auto"></p>
@@ -873,30 +873,26 @@ with SB(test=True, rtf=True, demo=True) as sb:
873873
This pure Python format gives you a raw <code translate="no">webdriver</code> instance in a <code translate="no">with</code> block. The SeleniumBase Driver Manager will automatically make sure that your driver is compatible with your browser version. It gives you full access to customize driver options via method args or via the command-line. The driver will automatically call <code translate="no">quit()</code> after the code leaves the <code translate="no">with</code> block. Here are some examples:
874874

875875
```python
876-
"""This script can be run with pure "python". (pytest not needed)."""
877-
from seleniumbase import js_utils
878-
from seleniumbase import page_actions
876+
"""Can run with "python". (pytest not needed)."""
879877
from seleniumbase import DriverContext
880878

881-
# Driver Context Manager - (By default, browser="chrome". Lots of options)
882879
with DriverContext() as driver:
883880
driver.get("https://seleniumbase.github.io/")
884-
js_utils.highlight_with_js(driver, 'img[alt="SeleniumBase"]', loops=6)
881+
driver.highlight('img[alt="SeleniumBase"]', loops=6)
885882

886883
with DriverContext(browser="chrome", incognito=True) as driver:
887884
driver.get("https://seleniumbase.io/apps/calculator")
888-
page_actions.wait_for_element(driver, '[id="4"]').click()
889-
page_actions.wait_for_element(driver, '[id="2"]').click()
890-
page_actions.wait_for_text(driver, "42", "#output")
891-
js_utils.highlight_with_js(driver, "#output", loops=6)
885+
driver.click('[id="4"]')
886+
driver.click('[id="2"]')
887+
driver.assert_text("42", "#output")
888+
driver.highlight("#output", loops=6)
892889

893890
with DriverContext() as driver:
894891
driver.get("https://seleniumbase.github.io/demo_page")
895-
js_utils.highlight_with_js(driver, "h2", loops=5)
896-
by_css = "css selector"
897-
driver.find_element(by_css, "#myTextInput").send_keys("Automation")
898-
driver.find_element(by_css, "#checkBox1").click()
899-
js_utils.highlight_with_js(driver, "img", loops=5)
892+
driver.highlight("h2")
893+
driver.type("#myTextInput", "Automation")
894+
driver.click("#checkBox1")
895+
driver.highlight("img", loops=6)
900896
```
901897

902898
(See <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_driver_context.py">examples/raw_driver_context.py</a> for an example.)
@@ -907,31 +903,48 @@ with DriverContext() as driver:
907903
Another way of running Selenium tests with pure ``python`` (as opposed to using ``pytest`` or ``pynose``) is by using this format, which bypasses [BaseCase](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py) methods while still giving you a flexible driver with a manager. SeleniumBase includes helper files such as [page_actions.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/page_actions.py), which may help you get around some of the limitations of bypassing ``BaseCase``. Here's an example:
908904

909905
```python
910-
"""This script can be run with pure "python". (pytest not needed)."""
906+
"""Driver() test. Runs with "python". (pytest not needed)."""
911907
from seleniumbase import Driver
912-
from seleniumbase import js_utils
913-
from seleniumbase import page_actions
914908

915-
# Example with options. (Also accepts command-line options.)
916909
driver = Driver(browser="chrome", headless=False)
917910
try:
918911
driver.get("https://seleniumbase.io/apps/calculator")
919-
page_actions.wait_for_element(driver, '[id="4"]').click()
920-
page_actions.wait_for_element(driver, '[id="2"]').click()
921-
page_actions.wait_for_text(driver, "42", "#output")
922-
js_utils.highlight_with_js(driver, "#output", loops=6)
912+
driver.click('[id="4"]')
913+
driver.click('[id="2"]')
914+
driver.assert_text("42", "#output")
915+
driver.highlight("#output", loops=6)
923916
finally:
924917
driver.quit()
925918

926-
# Example 2 using default args or command-line options
927919
driver = Driver()
928920
try:
929921
driver.get("https://seleniumbase.github.io/demo_page")
930-
js_utils.highlight_with_js(driver, "h2", loops=5)
931-
by_css = "css selector"
932-
driver.find_element(by_css, "#myTextInput").send_keys("Automation")
933-
driver.find_element(by_css, "#checkBox1").click()
934-
js_utils.highlight_with_js(driver, "img", loops=5)
922+
driver.highlight("h2")
923+
driver.type("#myTextInput", "Automation")
924+
driver.click("#checkBox1")
925+
driver.highlight("img", loops=6)
926+
finally:
927+
driver.quit()
928+
"""Driver() test. Runs with "python". (pytest not needed)."""
929+
from seleniumbase import Driver
930+
931+
driver = Driver(browser="chrome", headless=False)
932+
try:
933+
driver.get("https://seleniumbase.io/apps/calculator")
934+
driver.click('[id="4"]')
935+
driver.click('[id="2"]')
936+
driver.assert_text("42", "#output")
937+
driver.highlight("#output", loops=6)
938+
finally:
939+
driver.quit()
940+
941+
driver = Driver()
942+
try:
943+
driver.get("https://seleniumbase.github.io/demo_page")
944+
driver.highlight("h2")
945+
driver.type("#myTextInput", "Automation")
946+
driver.click("#checkBox1")
947+
driver.highlight("img", loops=6)
935948
finally:
936949
driver.quit()
937950
```

seleniumbase/config/proxy_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
Example proxies in PROXY_LIST below are not guaranteed to be active or secure.
1616
If you don't already have a proxy server to connect to,
1717
you can try finding one from one of following sites:
18+
* https://www.sslproxies.org/
1819
* https://bit.ly/36GtZa1
1920
* https://www.us-proxy.org/
2021
* https://hidemy.name/en/proxy-list/
2122
* http://free-proxy.cz/en/proxylist/country/all/https/ping/all
22-
* https://github.com/mertguvencli/http-proxy-list
2323
"""
2424

2525
PROXY_LIST = {

0 commit comments

Comments
 (0)