Skip to content

Allow use of all "page_actions.py" methods without using "BaseCase" #1317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<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>
<!-- View on GitHub -->

<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>
<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>

<p align="center">
<a href="https://github.com/seleniumbase/SeleniumBase/releases">
Expand Down
14 changes: 6 additions & 8 deletions examples/raw_browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
success = False
try:
driver = get_driver("chrome", headless=False)
driver.get('data:text/html,<h1 class="top">Data URL</h2>')
source = driver.page_source
assert "Data URL" in source
# An example of "is_element_visible()" from "page_actions"
assert page_actions.is_element_visible(driver, "h1.top")
# Extra fun with Javascript
js_utils.highlight_with_js(driver, "h1.top", 8, "")
success = True # No errors
driver.get("https://seleniumbase.io/apps/calculator")
page_actions.wait_for_element_visible(driver, "4", "id").click()
page_actions.wait_for_element_visible(driver, "2", "id").click()
page_actions.wait_for_text_visible(driver, "42", "output", "id")
js_utils.highlight_with_js(driver, "#output", 6, "")
success = True
finally:
driver.quit()
assert success
12 changes: 6 additions & 6 deletions help_docs/syntax_formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ from seleniumbase import page_actions
success = False
try:
driver = get_driver("chrome", headless=False)
driver.get('data:text/html,<h1 class="top">Data URL</h2>')
source = driver.page_source
assert "Data URL" in source
assert page_actions.is_element_visible(driver, "h1.top")
js_utils.highlight_with_js(driver, "h1.top", 8, "")
success = True # No errors
driver.get("https://seleniumbase.io/apps/calculator")
page_actions.wait_for_element_visible(driver, "4", "id").click()
page_actions.wait_for_element_visible(driver, "2", "id").click()
page_actions.wait_for_text_visible(driver, "42", "output", "id")
js_utils.highlight_with_js(driver, "#output", 6, "")
success = True
finally:
driver.quit()
assert success
Expand Down
2 changes: 1 addition & 1 deletion mkdocs_build/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bleach==5.0.0
jsmin==3.0.1
lunr==0.6.2
nltk==3.7
watchdog==2.1.7
watchdog==2.1.8
mkdocs==1.3.0
mkdocs-material==8.2.15
mkdocs-exclude-search==0.6.4
Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "3.0.1"
__version__ = "3.0.2"
29 changes: 20 additions & 9 deletions seleniumbase/drivers/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
### <img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> SeleniumBase webdriver storage
### <img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> SeleniumBase webdriver storage

* 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.

```bash
seleniumbase get chromedriver
seleniumbase get geckodriver
seleniumbase get edgedriver
seleniumbase get iedriver
seleniumbase get operadriver
```
seleniumbase install chromedriver
seleniumbase install geckodriver
seleniumbase install edgedriver
seleniumbase install iedriver
seleniumbase install operadriver
```
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.)

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.)

* 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>):

```bash
seleniumbase install chromedriver latest
sbase get chromedriver latest
```

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.

* You can also download specific versions of drivers. Examples:

```bash
sbase get chromedriver 101
sbase get chromedriver 101.0.4951.41
sbase get chromedriver latest-1
sbase get edgedriver 101.0.1210.32
```
16 changes: 8 additions & 8 deletions seleniumbase/fixtures/page_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
The default option for searching for elements is by CSS Selector.
This can be changed by overriding the "By" parameter.
Options are:
By.CSS_SELECTOR
By.CLASS_NAME
By.ID
By.NAME
By.LINK_TEXT
By.XPATH
By.TAG_NAME
By.PARTIAL_LINK_TEXT
By.CSS_SELECTOR # "css selector"
By.CLASS_NAME # "class name"
By.ID # "id"
By.NAME # "name"
By.LINK_TEXT # "link text"
By.XPATH # "xpath"
By.TAG_NAME # "tag name"
By.PARTIAL_LINK_TEXT # "partial link text"
"""

import codecs
Expand Down
6 changes: 5 additions & 1 deletion seleniumbase/fixtures/shared_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ def __time_limit_exceeded(message):


def check_if_time_limit_exceeded():
if sb_config.time_limit and not sb_config.recorder_mode:
if (
hasattr(sb_config, "time_limit")
and sb_config.time_limit
and not sb_config.recorder_mode
):
time_limit = sb_config.time_limit
now_ms = int(time.time() * 1000)
if now_ms > sb_config.start_time_ms + sb_config.time_limit_ms:
Expand Down