python-client for optimusCloud
Project description
Python-Client
Getting the Optimus Python client
There are three ways to install and use the Optimus Python client.
-
Install from PyPi, as Optimus-Python-Client
pip install Optimus-Python-Client
-
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
-
Install from source via GitHub.
git clone <path> cd python-client python setup.py install
Run Tests
-
With Python's unittest
-
Create
setUp
andtearDown
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
-
-
With pytest
-
Write
setup
andteardown
method in a classimport 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
-
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for Optimus-Python-Client-0.3.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 446ac38cdb2c6d6fac5ac6abd977b8e6eade5e93db6eb2c7e8f3a860f2d15c59 |
|
MD5 | 5ce8ff8d612f65d904f08dee5c645e80 |
|
BLAKE2b-256 | ba490e5b4bf4c55da51306d03067517f07bd3a6d868df03b4850e7d9b3bed87c |
Hashes for Optimus_Python_Client-0.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e891426c51e894b6d0695883e8592e5e098f63c570c0473fbf6d6151e5df1d80 |
|
MD5 | f883eb2fe6cf0375c0f5a277acce01d2 |
|
BLAKE2b-256 | 3a9849dc2719dc4c8c24c0d35d93b3ba8dbb00e039fb00b967304d77e466b763 |