Optimus

Optimus

  • Getting Started
  • Docs
  • Reporting
  • Roadmap
  • Contributors
  • Github

›Setting Up New Project

Getting Started

  • Getting Started

Installation

  • Optimus Cloud Installation

Setting Up New Project

  • Getting Started With TestNG
  • Getting Started With Cucumber
  • Getting Started With PyTest

Integration

  • TestNG Integration

Example Projects

  • Java Example Projects

Terminologies

  • Terminologies

Architecture

  • Bird View

Optimus-Python-Client

Installation

There are three ways to install and use the Optimus Python client.

  1. Install from PyPi, as Optimus-Python-Client

    pip install Optimus-Python-Client
    
  2. Install from source, via PyPi. From Optimus-Python-Client, download and unarchive the source tarball (Optimus-Python-Client-X.X.tar.gz).

    tar -xvf Optimus-Python-Client-X.X.tar.gz
    cd Optimus-Python-Client-X.X
    python setup.py install
    
  3. Install from source via GitHub.

    git clone <path>
    cd python-client
    python setup.py install
    

Run Tests

  1. With Python's unittest

    • Create setUp and tearDown method inside a class.

      import unittest
      
      from remote.OptimusCloudDriver import OptimusCloudDriver
      from remote.OptimusCloudManager import OptimusCloudManager
      
      class BaseTest(unittest.TestCase):
          def setUp(self) -> None:
              desired_caps = {
                  'platformName': 'Android',
                  'appPackage': 'com.cleartrip.android',
                  'appActivity': 'com.cleartrip.android.activity.common.SplashActivity'
              }
              self.mobileDriverDetails = OptimusCloudDriver().createDriver(desiredCapabilities=desired_caps)
              self.driver = self.mobileDriverDetails.mobileDriver
      
          def tearDown(self) -> None:
              OptimusCloudManager().releaseSession(self.mobileDriverDetails)
      
    • Write the test.

      class TestFile(BaseTest):
          def test_page_title(self):
              sleep(3)
              self.driver.find_element_by_id("classic_bottom_navigation_icon").click()
              assert self.driver.find_element_by_id("headerTxt").text == "Search Flights"
      
    • Run the tests

  1. With pytest

    • Write setup and teardown method in a class

      import pytest
      
      from remote.OptimusCloudDriver import OptimusCloudDriver
      from remote.OptimusCloudManager import OptimusCloudManager
      
      class DriverFactory(object):
          @pytest.fixture(scope='function', autouse=True)
          def setUp(self) -> None:
              desired_caps = {
                  'platformName': 'Android',
                  'appPackage': 'com.cleartrip.android',
                  'appActivity': 'com.cleartrip.android.activity.common.SplashActivity'
              }
              self.mobileDriverDetails = OptimusCloudDriver().createDriver(desiredCapabilities=desired_caps)
              self.driver = self.mobileDriverDetails.mobileDriver
      
          @pytest.fixture(scope='function', autouse=True)
          def tearDown(self) -> None:
              OptimusCloudManager().releaseSession(self.mobileDriverDetails)
      

      Read more about fixtures here

    • Write the Test class

      from time import sleep
      
      from test.DriverFactory import DriverFactory
      
      class TestPageTitle(DriverFactory):
          def test_page_title(self):
              sleep(3)
              self.driver.find_element_by_id("classic_bottom_navigation_icon").click()
              assert self.driver.find_element_by_id("headerTxt").text == "Search Flights"
      
    • Run the test

      pytest TestPageTitle.py 
      

Run tests in parallel

  • Parallelization can be achieved by using pytest-xdist

    • Install it via pip or pip3

      pip install pytest-xdist

      pip3 install pytest-xdist

    • Write multiple tests or test in multiple files

    • Run the test

      pytest -n <number of thread>

      pytest -n 2
      
← Getting Started With CucumberTestNG Integration →
  • Installation
    • Run Tests
Optimus
Docs
Getting Started (or other categories)Guides (or other categories)API Reference (or other categories)
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Facebook Open Source
Copyright © 2020 TestVagrant Technoligies