用于optimusCloud的pythonclient
Optimus-Python-Client的Python项目详细描述
Python客户端
获取Optimus Python客户端
有三种方法可以安装和使用optimuspython客户机。在
- 在
从PyPi安装,作为Optimus-Python-Client
在pip install Optimus-Python-Client
- 在
从源代码安装,通过PyPi。从Optimus-Python-Client,下载并取消归档源tarball(Optimus-Python-Client-X.X)。焦油.gz). 在
^{pr2}$ 在 - 在
通过GitHub从源安装。在
在git clone <path> cd python-client python setup.py install
运行测试
- 在
使用Python的unittest
- 在
在类中创建
setUp
和tearDown
方法。在importunittestfromremote.OptimusCloudDriverimportOptimusCloudDriverfromremote.OptimusCloudManagerimportOptimusCloudManagerclassBaseTest(unittest.TestCase):defsetUp(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.mobileDriverdeftearDown(self)->None:OptimusCloudManager().releaseSession(self.mobileDriverDetails)
在 - 在
写测试。在
classTestFile(BaseTest):deftest_page_title(self):sleep(3)self.driver.find_element_by_id("classic_bottom_navigation_icon").click()assertself.driver.find_element_by_id("headerTxt").text=="Search Flights"
在 - 在
运行测试
在
- 在
- 在
- 在
在类中编写
setup
和teardown
方法importpytestfromremote.OptimusCloudDriverimportOptimusCloudDriverfromremote.OptimusCloudManagerimportOptimusCloudManagerclassDriverFactory(object):@pytest.fixture(scope='function',autouse=True)defsetUp(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)deftearDown(self)->None:OptimusCloudManager().releaseSession(self.mobileDriverDetails)
阅读有关fixture的更多信息here
在 - 在
编写测试类
fromtimeimportsleepfromtest.DriverFactoryimportDriverFactoryclassTestPageTitle(DriverFactory):deftest_page_title(self):sleep(3)self.driver.find_element_by_id("classic_bottom_navigation_icon").click()assertself.driver.find_element_by_id("headerTxt").text=="Search Flights"
在 - 在
运行测试
在pytest TestPageTitle.py
- 在
并行运行测试
- 在
使用pytest-xdist可以实现并行化
- 在
通过pip或pip3安装
pip install pytest-xdist
在pip3 install pytest-xdist
- 在
编写多个测试或多个文件中的测试
在 - 在
运行测试
pytest -n <number of thread>
pytest -n 2
在
- 在
- 项目
标签: