Skip to content

Latest commit

 

History

History
536 lines (416 loc) · 12.5 KB

File metadata and controls

536 lines (416 loc) · 12.5 KB
sidebar_position title locale toc_max_heading_level
1
Routine Testing
en
4

import BrowserOnly from '@docusaurus/BrowserOnly'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import { getBrowserPlatform, BrowserPlatform, } from '@site/src/platform/platform.ts'; import routine_livestreaming_selenium_cross_python from '@site/static/img/routine/routine_livestreaming_selenium_cross_python.png';

Routine Testing

What is Routine Testing?

Routine Testing is a feature that integrate your test scripts (like pytest, jest or even if it's not a testing framework) with other CI systems, allowing you to periodically test with Dogu device farm.

How to use Routine Testing?

:::tip

We recommend you to do the Dogu Routine interactive tutorial first.

:::

1. Interactive Tutorial

:::info prerequisite

You need to create a project in Cloud Dogu Console before you can try the tutorial.
Please refer to Managing Projects for details.

:::

✅ Click the Routines button as shown below, and ✅ click the Tutorial button.

<img src="/img/get-started/routine-tutorial.png" style={{ width: 1000, display: 'block' }} />

🎉 Enjoy the tutorial! 🎉

2. Local Testing With Dogu Agent API

:::info prerequisite

You need to install the Dogu Agent in your local environment.

:::

:::tip

This is an example of using selenium for cross browsing testing.
You can refer to the dogu-routine-examples repository on GitHub for more examples.

:::

1. Checkout The dogu-routine-examples Repository On GitHub

This repository contains examples of using the Dogu Agent API for cross browsing testing with dogu-device-client.

dogu-device-client provides a set of APIs for controlling the Dogu Agent.

  • 🌎 Automatic installation of browser and web drivers for ⚔️ cross browsing testing.
    Auto installables: 🌐 chrome with chromedriver, 🦊 firefox with geckodriver, 📐 edge with edgedriver
  • 💾 Automatic download of project apps for app testing.
    Only when executed in Dogu Routine. If you want it to be available locally, please contact us.
  • 📱 Control of the built-in Appium Server for app testing.

2. Write Environment Variables To .env.local File

{() => (

We use dotenv to load environment variables from .env.local file and this file is not included in the repository for local testing.

// selenium/typescript/jest/web/setup.ts
import { config } from 'dotenv';
// ...
config({ path: '.env.local' });
// ...

Write the following environment variables to .env.local file on selenium/typescript/jest directory.

We use python-dotenv to load environment variables from .env.local file and this file is not included in the repository for local testing.

# selenium/python/pytest/web/conftest.py
from pathlib import Path
from dotenv import load_dotenv
# ...
load_dotenv(str(Path(__file__).parent.parent / '.env.local'))
# ...

Write the following environment variables to .env.local file on selenium/python/pytest directory.

)}
# .env.local
DOGU_BROWSER_NAME=chrome
DOGU_DEVICE_PLATFORM=macos # or windows
DOGU_DEVICE_SERIAL=
DOGU_DEVICE_TOKEN=

Go to Dogu Agent and click the button on the right side of the device to create the environment variables needed for testing. Copy the environment variables that appear later.

<img src="/img/get-started/routine-local-create-env1.png" style={{ width: 800, display: 'block' }} />

<img src="/img/get-started/routine-local-create-env2.png" style={{ width: 800, display: 'block' }} />

Paste the value copied to the clipboard into the .env.local file.

# .env.local
# ...
DOGU_DEVICE_SERIAL=<your device serial>
DOGU_DEVICE_TOKEN=<your device token>

3. Run Test Script Locally

{() => (

Run command on selenium/typescript/jest directory.

npm install
npm run test:web

Run command on selenium/python/pytest directory.

python3 -m venv .venv
source .venv/bin/activate
pip3 install -r requirements.txt
pytest web/test_web.py --capture=no -x
)}

🎉 Local testing with Dogu Agent API is complete! 🎉

3. Test Running With Dogu Device Farm Using Dogu Routine

Dogu Routine can be integrated with other CI systems such as GitHub Actions, Jenkins, Bitbucket.
If you want to integrate with other CI systems, please connect us.

1. Write Routine Yaml

:::info

You can see the Managing Routine for details on how to write the routine yaml.

:::

Add the sample below to your project routine.

{() => ( {() => (
name: cross-browsing-testing-typescript-macos

'on':
  workflow_dispatch: null

jobs:
  test-chrome:
    runs-on: macos
    browserName: chrome
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: node
          command: |-
            npm install
            npm run test:web
        cwd: selenium/typescript/jest
    record: true

  test-firefox:
    runs-on: macos
    browserName: firefox
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: node
          command: |-
            npm install
            npm run test:web
        cwd: selenium/typescript/jest
    record: true

  test-edge:
    runs-on: macos
    browserName: edge
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: node
          command: |-
            npm install
            npm run test:web
        cwd: selenium/typescript/jest
    record: true

  test-safari:
    runs-on: macos
    browserName: safari
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: node
          command: |-
            npm install
            npm run test:web
        cwd: selenium/typescript/jest
    record: true
name: cross-browsing-testing-typescript-windows

'on':
  workflow_dispatch: null

jobs:
  test-chrome:
    runs-on: windows
    browserName: chrome
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: node
          command: |-
            npm install
            npm run test:web
        cwd: selenium/typescript/jest
    record: true

  test-firefox:
    runs-on: windows
    browserName: firefox
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: node
          command: |-
            npm install
            npm run test:web
        cwd: selenium/typescript/jest
    record: true

  test-edge:
    runs-on: windows
    browserName: edge
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: node
          command: |-
            npm install
            npm run test:web
        cwd: selenium/typescript/jest
    record: true
)} {() => (
name: cross-browsing-testing-python-macos

'on':
  workflow_dispatch: null

jobs:
  test-chrome:
    runs-on: macos
    browserName: chrome
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: python
          command: |-
            pip3 install -r requirements.txt
            pytest web/test_web.py --capture=no -x
        cwd: selenium/python/pytest
    record: true

  test-firefox:
    runs-on: macos
    browserName: firefox
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: python
          command: |-
            pip3 install -r requirements.txt
            pytest web/test_web.py --capture=no -x
        cwd: selenium/python/pytest
    record: true

  test-edge:
    runs-on: macos
    browserName: edge
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: python
          command: |-
            pip3 install -r requirements.txt
            pytest web/test_web.py --capture=no -x
        cwd: selenium/python/pytest
    record: true

  test-safari:
    runs-on: macos
    browserName: safari
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: python
          command: |-
            pip3 install -r requirements.txt
            pytest web/test_web.py --capture=no -x
        cwd: selenium/python/pytest
    record: true
name: cross-browsing-testing-python-windows

'on':
  workflow_dispatch: null

jobs:
  test-chrome:
    runs-on: windows
    browserName: chrome
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: python
          command: |-
            pip3 install -r requirements.txt
            pytest web/test_web.py --capture=no -x
        cwd: selenium/python/pytest
    record: true

  test-firefox:
    runs-on: windows
    browserName: firefox
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: python
          command: |-
            pip3 install -r requirements.txt
            pytest web/test_web.py --capture=no -x
        cwd: selenium/python/pytest
    record: true

  test-edge:
    runs-on: windows
    browserName: edge
    steps:
      - name: run test
        uses: dogu-actions/run-test
        with:
          checkout: true
          environment: python
          command: |-
            pip3 install -r requirements.txt
            pytest web/test_web.py --capture=no -x
        cwd: selenium/python/pytest
    record: true
)} )}

2. Change Max Parallel Jobs Count on Your Host Device

Change the max parallel jobs count to 8 on your host device for the parallel execution of the Jobs.

:::info

see Managing Device for details on how to change the max parallel jobs count.

:::

3. Create Your Github Token

:::info

see Generate GitHub Token for details on how to create Github Token.

:::

4. Integrate With GitHub

:::info

see Git Integration for details on how to integrate with GitHub.

:::

5. Run The Routine

:::info

see Run a Routine for details on how to run a routine.

:::

🎉 Test Running With Dogu Device Farm Using Dogu Routine! 🎉

  • <img src={routine_livestreaming_selenium_cross_python} style={{ width: 800 }} />

4. Integration With Other CI Systems for Routine Testing

:::info

see CI/CD for details on how to integrate with other CI systems.

:::

If you want to integrate with other CI systems, please connect us.

🎉 Integration with other CI systems for routine testing is complete! 🎉

import DocCardList from '@theme/DocCardList';

<DocCardList />