Merge pull request #1317 from seleniumbase/page-actions-without-basecase
Allow use of all "page_actions.py" methods without using "BaseCase"
This commit is contained in:
commit
da0af4f859
|
@ -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">
|
||||
|
|
|
@ -9,14 +9,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
|
||||
# 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
# seleniumbase package
|
||||
__version__ = "3.0.1"
|
||||
__version__ = "3.0.2"
|
||||
|
|
|
@ -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
|
||||
```
|
||||
|
|
|
@ -9,14 +9,14 @@ by giving page elements enough time to load before taking action on them.
|
|||
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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue