Skip to content

Commit da0af4f

Browse files
authored
Merge pull request #1317 from seleniumbase/page-actions-without-basecase
Allow use of all "page_actions.py" methods without using "BaseCase"
2 parents b0563d5 + f82b809 commit da0af4f

File tree

8 files changed

+48
-35
lines changed

8 files changed

+48
-35
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<h3 align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/mac_sb_logo_9.png" alt="SeleniumBase" title="SeleniumBase" width="340" /></a></h3>
99
<!-- View on GitHub -->
1010

11-
<p align="center"><div align="center">A Python framework for <a href="https://www.selenium.dev/documentation/" target="_blank">Selenium</a>. Supports <a href="https://docs.pytest.org/en/stable/" target="_blank">pytest</a> and <a href="https://behave.readthedocs.io/en/stable/index.html" target="_blank">behave-BDD</a>.</div></p>
11+
<p align="center"><div align="center">Python framework for <a href="https://www.selenium.dev/documentation/" target="_blank">Selenium</a>. Supports <a href="https://docs.pytest.org/en/stable/" target="_blank">pytest</a> and <a href="https://behave.readthedocs.io/en/stable/index.html" target="_blank">behave-BDD</a>.</div></p>
1212

1313
<p align="center">
1414
<a href="https://github.com/seleniumbase/SeleniumBase/releases">

examples/raw_browser_launcher.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
success = False
1010
try:
1111
driver = get_driver("chrome", headless=False)
12-
driver.get('data:text/html,<h1 class="top">Data URL</h2>')
13-
source = driver.page_source
14-
assert "Data URL" in source
15-
# An example of "is_element_visible()" from "page_actions"
16-
assert page_actions.is_element_visible(driver, "h1.top")
17-
# Extra fun with Javascript
18-
js_utils.highlight_with_js(driver, "h1.top", 8, "")
19-
success = True # No errors
12+
driver.get("https://seleniumbase.io/apps/calculator")
13+
page_actions.wait_for_element_visible(driver, "4", "id").click()
14+
page_actions.wait_for_element_visible(driver, "2", "id").click()
15+
page_actions.wait_for_text_visible(driver, "42", "output", "id")
16+
js_utils.highlight_with_js(driver, "#output", 6, "")
17+
success = True
2018
finally:
2119
driver.quit()
2220
assert success

help_docs/syntax_formats.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,12 @@ from seleniumbase import page_actions
235235
success = False
236236
try:
237237
driver = get_driver("chrome", headless=False)
238-
driver.get('data:text/html,<h1 class="top">Data URL</h2>')
239-
source = driver.page_source
240-
assert "Data URL" in source
241-
assert page_actions.is_element_visible(driver, "h1.top")
242-
js_utils.highlight_with_js(driver, "h1.top", 8, "")
243-
success = True # No errors
238+
driver.get("https://seleniumbase.io/apps/calculator")
239+
page_actions.wait_for_element_visible(driver, "4", "id").click()
240+
page_actions.wait_for_element_visible(driver, "2", "id").click()
241+
page_actions.wait_for_text_visible(driver, "42", "output", "id")
242+
js_utils.highlight_with_js(driver, "#output", 6, "")
243+
success = True
244244
finally:
245245
driver.quit()
246246
assert success

mkdocs_build/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ bleach==5.0.0
2323
jsmin==3.0.1
2424
lunr==0.6.2
2525
nltk==3.7
26-
watchdog==2.1.7
26+
watchdog==2.1.8
2727
mkdocs==1.3.0
2828
mkdocs-material==8.2.15
2929
mkdocs-exclude-search==0.6.4

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__ = "3.0.1"
2+
__version__ = "3.0.2"

seleniumbase/drivers/ReadMe.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
1-
### <img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> SeleniumBase webdriver storage
1+
### <img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> SeleniumBase webdriver storage
22

33
* You need a different webdriver for each web browser you want to run automation on: ``chromedriver`` for Chrome, ``edgedriver`` for Edge, ``geckodriver`` for Firefox, ``operadriver`` for Opera, and ``iedriver`` for Internet Explorer.
44

5+
```bash
6+
seleniumbase get chromedriver
7+
seleniumbase get geckodriver
8+
seleniumbase get edgedriver
9+
seleniumbase get iedriver
10+
seleniumbase get operadriver
511
```
6-
seleniumbase install chromedriver
7-
seleniumbase install geckodriver
8-
seleniumbase install edgedriver
9-
seleniumbase install iedriver
10-
seleniumbase install operadriver
11-
```
12-
After running the commands above, web drivers will get downloaded into this folder. SeleniumBase will then use those drivers during test runs if present. (The drivers don't come with SeleniumBase by default.)
12+
13+
After running the commands above, web drivers will get downloaded into this folder. SeleniumBase will then use those drivers during tests if present. (The drivers don't come with SeleniumBase by default.)
1314

1415
* If you have the latest version of Chrome installed, get the latest chromedriver (<i>otherwise it defaults to chromedriver 2.44 for compatibility reasons</i>):
16+
1517
```bash
16-
seleniumbase install chromedriver latest
18+
sbase get chromedriver latest
1719
```
1820

1921
If the necessary driver is not found in this location while running tests, SeleniumBase will instead look for the driver on the System PATH. If the necessary driver is not on the System PATH either, SeleniumBase will automatically attempt to download the required driver.
22+
23+
* You can also download specific versions of drivers. Examples:
24+
25+
```bash
26+
sbase get chromedriver 101
27+
sbase get chromedriver 101.0.4951.41
28+
sbase get chromedriver latest-1
29+
sbase get edgedriver 101.0.1210.32
30+
```

seleniumbase/fixtures/page_actions.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
The default option for searching for elements is by CSS Selector.
1010
This can be changed by overriding the "By" parameter.
1111
Options are:
12-
By.CSS_SELECTOR
13-
By.CLASS_NAME
14-
By.ID
15-
By.NAME
16-
By.LINK_TEXT
17-
By.XPATH
18-
By.TAG_NAME
19-
By.PARTIAL_LINK_TEXT
12+
By.CSS_SELECTOR # "css selector"
13+
By.CLASS_NAME # "class name"
14+
By.ID # "id"
15+
By.NAME # "name"
16+
By.LINK_TEXT # "link text"
17+
By.XPATH # "xpath"
18+
By.TAG_NAME # "tag name"
19+
By.PARTIAL_LINK_TEXT # "partial link text"
2020
"""
2121

2222
import codecs

seleniumbase/fixtures/shared_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ def __time_limit_exceeded(message):
7676

7777

7878
def check_if_time_limit_exceeded():
79-
if sb_config.time_limit and not sb_config.recorder_mode:
79+
if (
80+
hasattr(sb_config, "time_limit")
81+
and sb_config.time_limit
82+
and not sb_config.recorder_mode
83+
):
8084
time_limit = sb_config.time_limit
8185
now_ms = int(time.time() * 1000)
8286
if now_ms > sb_config.start_time_ms + sb_config.time_limit_ms:

0 commit comments

Comments
 (0)