Skip to content

Commit

Permalink
Docker Mobile Android
Browse files Browse the repository at this point in the history
  • Loading branch information
tauqirsarwar1 committed Mar 19, 2024
1 parent 01f0f2c commit 976db80
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 33 deletions.
37 changes: 28 additions & 9 deletions .github/workflows/docker_android_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
docker-manual-android-run:
if: github.event_name != 'schedule'
name: Manual - ${{ inputs.tags }}
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: Validate Input Parameter
id: validate_input
Expand All @@ -89,28 +89,47 @@ jobs:
if: steps.setup_python.outcome == 'success'
uses: actions/checkout@v4

- name: Setup Java
id: setup_java
if: steps.co_code.outcome == 'success'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Install and Run Appium Server
uses: moatazeldebsy/[email protected]
id: setup_appium
if: steps.setup_java.outcome == 'success'
run: |
npm install -g appium
appium --log-level info &
sleep 5
appium -v
appium &>dev/null &
- name: Setup dependencies
id: setup_dependencies
if: steps.co_code.outcome == 'success'
run: |
sh install.sh
- name: Run Manual Job Tests
- name: Run Env Job Tests
id: run_manual_job
if: steps.setup_dependencies.outcome == 'success'
run: |
TAGS="${{ github.event.inputs.tags }}"
env
source $HOME/.bp-venv/bin/activate
python -m pytest -v --driver Appium \
--selenium-host 'localhost' --selenium-host '4723'\
--variables './configs/android_mobile_docker.json' \
--tags="$TAGS" --html=report.html \
--self-contained-html
- name: run android tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
script: python -m pytest -v --driver Appium --selenium-host 'localhost' --selenium-port '4723' \
--variables './configs/android_mobile_docker.json'
--tags="$TAGS" \
--html=report.html \
--self-contained-html \

- name: Upload HTML run report in the Artifacts Folder
uses: actions/upload-artifact@v4
Expand Down
42 changes: 21 additions & 21 deletions bp_core/frontend/frontend_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@


def pytest_bdd_before_scenario(
request: FixtureRequest,
feature: pytest_bdd_parser.Feature,
scenario: pytest_bdd_parser.Scenario,
request: FixtureRequest,
feature: pytest_bdd_parser.Feature,
scenario: pytest_bdd_parser.Scenario,
):
"""Called before every scenario execution"""
request.node.scenarioDict = defaultdict()
Expand All @@ -43,7 +43,7 @@ def pytest_bdd_before_scenario(

# Add logging after each scenario
def pytest_bdd_after_scenario(
feature: pytest_bdd_parser.Feature, scenario: pytest_bdd_parser.Scenario
feature: pytest_bdd_parser.Feature, scenario: pytest_bdd_parser.Scenario
):
"""Called after every scenario is executed"""
logger.info(
Expand All @@ -55,10 +55,10 @@ def pytest_bdd_after_scenario(

# Add logging for each step
def pytest_bdd_after_step(
request: FixtureRequest,
feature: pytest_bdd_parser.Feature,
scenario: pytest_bdd_parser.Scenario,
step: pytest_bdd_parser.Step
request: FixtureRequest,
feature: pytest_bdd_parser.Feature,
scenario: pytest_bdd_parser.Scenario,
step: pytest_bdd_parser.Step
):
"""Called after every step execution"""
logger.info(
Expand Down Expand Up @@ -94,7 +94,6 @@ def pytest_bdd_step_error(request: FixtureRequest,
feature: pytest_bdd_parser.Feature,
scenario: pytest_bdd_parser.Scenario,
step: pytest_bdd_parser.Step, exception):

"""Called on step error. Logs the error and takes a screenshot."""
_step_error(exception, feature, scenario, step)

Expand All @@ -111,9 +110,9 @@ def chrome_options(chrome_options, variables, proxy_url, env_variables, request)
caps = copy.deepcopy(request.getfixturevalue("session_capabilities"))

if (caps.get("headless", "") == "True") or (
"capabilities" in variables
and "headless" in variables["capabilities"]
and variables["capabilities"]["headless"] == "True"
"capabilities" in variables
and "headless" in variables["capabilities"]
and variables["capabilities"]["headless"] == "True"
):
chrome_options.add_argument("--headless")
caps.pop("headless", None)
Expand Down Expand Up @@ -293,6 +292,7 @@ def driver_kwargs(capabilities, host, port, **kwargs): # noqa

remote.driver_kwargs = driver_kwargs


# Define selenium generics as a fixture
# This is UI specific implementation
@pytest.fixture
Expand Down Expand Up @@ -325,15 +325,15 @@ def capabilities(capabilities):
# This is a temporary solution until the pytest-selenium fix the support for the Selenium 4.10+
@pytest.fixture
def driver_kwargs(
request,
chrome_options,
driver_args,
driver_class,
driver_log,
driver_path,
firefox_options,
edge_options,
pytestconfig,
request,
chrome_options,
driver_args,
driver_class,
driver_log,
driver_path,
firefox_options,
edge_options,
pytestconfig,
):
kwargs = {}
driver = getattr(drivers, pytestconfig.getoption("driver").lower())
Expand Down
4 changes: 1 addition & 3 deletions configs/android_mobile_docker.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"capabilities": {
"browserstack": "False",
"automationName": "UiAutomator1",
"deviceName": "Android Emulator",
"deviceName": "emulator-5554",
"platformName": "Android",
"platformVersion": "7.1.1",
"app": "app files/builds/Android-MyDemoAppRN.1.3.0.build-244.apk",
"noReset": false,
"newCommandTimeout": 3600
Expand Down

0 comments on commit 976db80

Please sign in to comment.