用于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第三方库


热门话题
java如何使用JPA从1自动生成id?   java JSONException:CourseVide没有值   在Java中使用身份和访问管理   java观察者设计如何访问方法。调用范围?   试图从Java源代码调用JavaScript函数   java How to Fix无法解析Android中的方法“setContentView”   java如何从非结构化日志文件中提取json字符串?   将java布尔结果转换为字符串值   java无法调试servlet Eclipse+Glassfish   java是检查布尔值数组是否包含true的最快方法   java JFrame不会显示在ubuntu上   面向Web应用的javascript图像编辑   使用Hadoop自定义数据类型biginsghts时出现java EOF异常   选择尽可能多的非重叠段时超出了java时间限制   从Firebase获取数据列表并在不同活动/片段中共享的java最佳实践   使用SimpleCursorAdapter时出现java空指针异常   java以升序将元素插入到多链接列表中   支持TDD的java Eclipse插件   客户端无法从Java代码向服务器发送命令