Skip to content

Commit

Permalink
Merge pull request #204 from ElSnoMan/logging
Browse files Browse the repository at this point in the history
Remove unused pylog_level setting
  • Loading branch information
ElSnoMan authored Jul 12, 2021
2 parents 6e9c099 + f080d73 commit 887d081
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 25 deletions.
4 changes: 0 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@ def py_config(project_root, request) -> PyleniumConfig:
config.driver.page_load_wait_time = int(cli_page_wait_time)

# Logging Settings
cli_pylog_level = request.config.getoption('--pylog_level')
if cli_pylog_level:
config.logging.pylog_level = cli_pylog_level

cli_screenshots_on = request.config.getoption('--screenshots_on')
if cli_screenshots_on:
shots_on = True if cli_screenshots_on.lower() == 'true' else False
Expand Down
5 changes: 1 addition & 4 deletions pylenium.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@
"extension_paths": [],
"local_path": ""
},

"logging": {
"screenshots_on": true,
"pylog_level": "info"
"screenshots_on": true
},

"viewport": {
"maximize": true,
"width": 1440,
Expand Down
21 changes: 13 additions & 8 deletions pylenium/jquery.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support.wait import WebDriverWait
from selenium.common.exceptions import StaleElementReferenceException
from pylenium import utils


def inject(driver: WebDriver, version='3.5.1', timeout=10):
""" Inject the given jQuery version to the current context and any iframes within it.
"""Inject the given jQuery version to the current context and any iframes within it.
Args:
driver: The instance of WebDriver to attach to.
Expand All @@ -15,15 +16,20 @@ def inject(driver: WebDriver, version='3.5.1', timeout=10):
jquery_url = f'https://code.jquery.com/jquery-{version}.min.js'
load_jquery = utils.read_script_from_file('load_jquery.js')
driver.execute_async_script(load_jquery, jquery_url, None)
WebDriverWait(driver, timeout).until(lambda drvr: drvr.execute_script('return typeof(jQuery) !== "undefined";'),
message='jQuery was "undefined" which means it did not load within timeout.')
WebDriverWait(driver, timeout).until(
lambda drvr: drvr.execute_script('return typeof(jQuery) !== "undefined";'),
message='jQuery was "undefined" which means it did not load within timeout.',
)
iframes = driver.find_elements_by_tag_name('iframe')
for iframe in iframes:
driver.execute_async_script(load_jquery, jquery_url, iframe)
try:
driver.execute_async_script(load_jquery, jquery_url, iframe)
except StaleElementReferenceException:
pass


def exists(driver: WebDriver) -> str:
""" Checks if jQuery exists in the current context.
"""Checks if jQuery exists in the current context.
Returns:
The version if found, else returns an empty string
Expand All @@ -33,7 +39,7 @@ def exists(driver: WebDriver) -> str:


def drag_and_drop(driver: WebDriver, drag_element: WebElement, drop_element: WebElement, version='3.5.1', timeout=10):
""" Simulate Drag and Drop using jQuery.
"""Simulate Drag and Drop using jQuery.
Args:
driver: The driver that will simulate the drag and drop.
Expand All @@ -45,6 +51,5 @@ def drag_and_drop(driver: WebDriver, drag_element: WebElement, drop_element: Web
inject(driver, version)
dnd_js = utils.read_script_from_file('drag_and_drop.js')
driver.execute_script(
dnd_js +
"jQuery(arguments[0]).simulateDragDrop({ dropTarget: arguments[1] });", drag_element, drop_element
dnd_js + "jQuery(arguments[0]).simulateDragDrop({ dropTarget: arguments[1] });", drag_element, drop_element
)
4 changes: 0 additions & 4 deletions pylenium/scripts/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@ def py_config(project_root, request) -> PyleniumConfig:
config.driver.page_load_wait_time = int(cli_page_wait_time)

# Logging Settings
cli_pylog_level = request.config.getoption('--pylog_level')
if cli_pylog_level:
config.logging.pylog_level = cli_pylog_level

cli_screenshots_on = request.config.getoption('--screenshots_on')
if cli_screenshots_on:
shots_on = True if cli_screenshots_on.lower() == 'true' else False
Expand Down
5 changes: 1 addition & 4 deletions pylenium/scripts/pylenium.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@
"extension_paths": [],
"local_path": ""
},

"logging": {
"screenshots_on": true,
"pylog_level": "info"
"screenshots_on": true
},

"viewport": {
"maximize": true,
"width": 1440,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyleniumio"
version = "1.12.5"
version = "1.12.8"
description = "The best of Selenium and Cypress in a single Python Package"
authors = ["Carlos <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 887d081

Please sign in to comment.