Skip to content

Commit

Permalink
Develop (#125)
Browse files Browse the repository at this point in the history
### To be filled by the PR creator:

* A brief description of the changes made - 

* Do we have clean latest run report (Docker or Browserstack) attached
with this PR?
  * [ ] Yes
  * [ ] No (Please explain why)

* Does the PR contain changes to any core file?
  * [ ] Yes (Needs approval from at least 1 people)
  * [ ] No

* Is it
  * [ ] New Testcase
  * [ ] Fix


### To be filled by the PR reviewer:

* [ ] Verify the attached run report passed in GitHub Actions (Docker or
Browserstack run)

* General
    * [ ] Use the best strategy to locate the elements
    * [ ] Comments wherever the code is not readable by itself
    * [ ] Use of the right data structure for the use case
    * [ ] Reuse logic/functionality as much as possible
    * [ ] Cleanup of any test data that is generated by the tests
    * [ ] No static waits
  • Loading branch information
tauqirsarwar1 authored May 8, 2024
2 parents 9c85ae5 + e292c89 commit d1a5aec
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ This document assumes that user has:

```shell
mkdir workspaces && cd workspaces
git clone https://github.com/modus/pytest-automation-boilerplate.git
git clone https://github.com/tweag/pytest-automation-boilerplate.git
# alternatively, you could use ssh link if you have setup ssh in your work machine.
```

Expand Down
2 changes: 2 additions & 0 deletions env_configs/.local.env
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ API_BASE_URL=https://jsonplaceholder.typicode.com
#Open AI
OPEN_KEY=
USING_DOCKER=
# BROWSERSTACK , SAUCELABS
USING_ENV=
14 changes: 14 additions & 0 deletions env_configs/souce_labs/android_mobile_SL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"capabilities": {
"platformVersion": "10",
"deviceName": "Samsung Galaxy S9",
"platformName": "Android",
"app": "storage:filename=Android-MyDemoAppRN.1.3.0.build-244.apk",
"appiumVersion": "latest",
"sauce:options": {
"build": "Pytest-Automation-Boilerplate",
"name": "Android App Tests",
"extendedDebugging": true
}
}
}
14 changes: 14 additions & 0 deletions env_configs/souce_labs/ios_mobile_SL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"capabilities": {
"platformVersion": "16.7",
"deviceName": "iPhone 12",
"platformName": "iOS",
"app": "storage:filename=iOS-Real-Device-MyRNDemoApp.1.3.0-162.ipa",
"appiumVersion": "latest",
"sauce:options": {
"build": "Pytest-Automation-Boilerplate",
"name": "IOS App Tests",
"extendedDebugging": true
}
}
}
12 changes: 12 additions & 0 deletions env_configs/souce_labs/win_chrome_SL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"capabilities": {
"browserName": "Chrome",
"browserVersion": "latest",
"platformName": "Windows 11",
"sauce:options": {
"build": "Pytest-Automation-Boilerplate",
"name": "Web UI Tests",
"extendedDebugging": true
}
}
}
45 changes: 45 additions & 0 deletions main/frontend/frontend_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,30 @@ def driver_kwargs(capabilities, host, **kwargs): # noqa
appium.driver_kwargs = driver_kwargs
remote.driver_kwargs = driver_kwargs

elif os.environ.get("USING_ENV", "") == 'SAUCELABS' and session_capabilities.get("platformName", "").lower() in (
"android", "ios"):
value, options = driver_options_factory

for k, v in session_capabilities.items():
options.set_capability(k, v)

def driver_kwargs(capabilities, host, port, **kwargs): # noqa
_ = capabilities
if value in ("chrome", "edge", "firefox"):
browser_options = kwargs.get(f"{value}_options", None)
browser_options_arguments = getattr(browser_options, "arguments", [])
browser_options_capabilities = getattr(browser_options, "capabilities", {})
options.capabilities.update(browser_options_capabilities)
options.arguments.extend([x for x in browser_options_arguments if x not in options.arguments])

executor = f"https://{host}:443/wd/hub"
kwargs = {"command_executor": executor, "options": options}

return kwargs

remote.driver_kwargs = driver_kwargs
appium.driver_kwargs = driver_kwargs

# To pass options for local Android and iOS test executions
elif session_capabilities.get("platformName", "").lower() in ("android", "ios"):
value, options = driver_options_factory
Expand Down Expand Up @@ -295,6 +319,27 @@ def driver_kwargs(capabilities, host, port, **kwargs): # noqa

remote.driver_kwargs = driver_kwargs

elif os.environ.get("USING_ENV", "") == 'SAUCELABS':
value, options = driver_options_factory

for k, v in session_capabilities.items():
options.set_capability(k, v)

def driver_kwargs(capabilities, host, port, **kwargs): # noqa
_ = capabilities
if value in ("chrome", "edge", "firefox"):
browser_options = kwargs.get(f"{value}_options", None)
browser_options_arguments = getattr(browser_options, "arguments", [])
browser_options_capabilities = getattr(browser_options, "capabilities", {})
options.capabilities.update(browser_options_capabilities)
options.arguments.extend([x for x in browser_options_arguments if x not in options.arguments])

executor = f"https://{host}:443/wd/hub"
kwargs = {"command_executor": executor, "options": options}

return kwargs

remote.driver_kwargs = driver_kwargs

# Define selenium generics as a fixture
# This is UI specific implementation
Expand Down

0 comments on commit d1a5aec

Please sign in to comment.