用于optimusCloud的pythonclient

Optimus-Python-Client的Python项目详细描述


Python客户端

获取Optimus Python客户端

有三种方法可以安装和使用optimuspython客户机。在

  1. PyPi安装,作为Optimus-Python-Client

    pip install Optimus-Python-Client
    
  2. 从源代码安装,通过PyPi。从Optimus-Python-Client,下载并取消归档源tarball(Optimus-Python-Client-X.X)。焦油.gz). 在

    ^{pr2}$ 在
  3. 通过GitHub从源安装。在

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

运行测试

  1. 使用Python的unittest

    • 在类中创建setUptearDown方法。在

      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"
    • 运行测试

  2. pytest

    • 在类中编写setupteardown方法

      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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
orm如何在Java中实现规范化映射?   java以编程方式修改Xtext生成的Mwe2工作流   java正在覆盖外部文件中的现有数据,如何停止?   java在ANTLR BNF语法符号中epsilon的等价物是什么?   java如何使用Hibernate@Anyrelated注释?   代码生成生成java类并在运行时加载它   java Maven无法在本地jar文件中收集依赖项   java NetBeans IDE 8.2不显示错误消息   java Selenium web驱动程序找不到元素   java如何修复“拒绝访问属性”invoke“”的权限?   JavaApacheJClouds,从比日期更早的blob中删除blob的最佳方法   java如何比较和排序树集中的项目?   使用JavaSpring和无头/解耦CMS   java使用swagercodegen在不同的类中生成端点   Java外部Keylistener没有响应