Skip to content

Commit

Permalink
Merge pull request #71 from ElSnoMan/caps-in-cli
Browse files Browse the repository at this point in the history
--caps CLI arg
  • Loading branch information
ElSnoMan authored Apr 24, 2020
2 parents d69783f + d2a8d33 commit a2ae2d2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
18 changes: 14 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ def py_config(project_root, request) -> PyleniumConfig:
if cli_browser_options:
config.driver.options = [option.strip() for option in cli_browser_options.split(',')]

cli_browser = request.config.getoption('--browser')
if cli_browser:
config.driver.browser = cli_browser

cli_capabilities = request.config.getoption('--caps')
if cli_capabilities:
# --caps must be in '[{}, {}]' format
# with double quotes around each key and value
config.driver.capabilities = json.loads(cli_capabilities)

# Logging Settings
cli_pylog_level = request.config.getoption('--pylog_level')
if cli_pylog_level:
Expand All @@ -126,10 +136,6 @@ def py_config(project_root, request) -> PyleniumConfig:
shots_on = True if cli_screenshots_on.lower() == 'true' else False
config.logging.screenshots_on = shots_on

cli_browser = request.config.getoption('--browser')
if cli_browser:
config.driver.browser = cli_browser

return config


Expand Down Expand Up @@ -203,3 +209,7 @@ def pytest_addoption(parser):
'--options', action='store',
default='', help='Comma-separated list of Browser Options. Ex. "headless, incognito"'
)
parser.addoption(
'--caps', action='store',
default='', help='List of key-value pairs. Ex. "[{}, {}]"'
)
3 changes: 2 additions & 1 deletion pylenium/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DriverConfig(BaseModel):
remote_url: str = ''
wait_time: int = 10
options: List[str] = []
capabilities: List[dict] = [{}]
capabilities: List[dict] = []
version: str = 'latest'


Expand All @@ -34,6 +34,7 @@ class PyleniumConfig(BaseModel):
viewport: ViewportConfig = ViewportConfig()
custom: dict = {}


# MODELS #
##########

Expand Down
2 changes: 1 addition & 1 deletion pylenium/webdriver_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def build_remote(browser: str, remote_url: str, browser_options: List[str], capa
elif browser == 'edge':
caps = webdriver.DesiredCapabilities.EDGE.copy()
else:
caps = None
caps = {}

if capabilities:
caps = capabilities
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='pyleniumio',
version='1.5.0',
version='1.5.1',
packages=[
'pylenium'
],
Expand Down

0 comments on commit a2ae2d2

Please sign in to comment.