新手学Appium_Python_Client

原文转自http://blog.sina.com.cn/s/blog_68f262210102v538.html

一,Appium_Python_Client的安装

推荐使用pip安装

    pip install Appium-Python-Client

当然了也可以在Pipy上下载源码安装

    tar -xvf Appium-Python-Client-X.X.tar.gz(windows上用7zip可以解压)

    cd Appium-Python-Client-X.X

    python setup.py install

最后,也可以通过github安装(要git客户端)

    git clone git@github.com:appium/python-client.git

    cd python-client

    python setup.py install

二,Appium_Python_Client介绍

   Appium的实用方法都藏在Client的源码里,对于driver和webelement实例,均有对应的元素查找方法(webelement查找的是下面的子元素),有些儿专门针对手机的函数,则需要在这个Client安装后方可使用。

(以下内容转自:http://testerhome.com/topics/1166

appium为了实现自己的find查找方式,首先自定义了一个MobileBy类,给这个类对象塞入了它定义的一些扩展属性,这些属性的值会通过webdriver协议推送到server端去识别和执行,为了让这些属性运用到find方法中,appium很好地继承和扩展了webdriver.Remote,然后通过调用driver实例的find_element和find_elements两个核心方法实现元素查找,所以,既然是扩展,appiumdriver实例可以使用seleniumdriver的所有关于元素查找的实例方法,他们的列表我们就可以整理出来了

seleniumdriver

find_element_by_id
find_elements_by_id
find_element_by_name
find_elements_by_name
find_element_by_link_text
find_elements_by_link_text
find_element_by_partial_link_text
find_elements_by_partial_link_text
find_element_by_tag_name
find_elements_by_tag_name
find_element_by_xpath
find_elements_by_xpath
find_element_by_class_name
find_elements_by_class_name
find_element_by_css_selector
find_elements_by_css_selector

appiumdriver

find_element_by_ios_uiautomation
find_elements_by_ios_uiautomation
find_element_by_android_uiautomator
find_elements_by_android_uiautomator
find_element_by_accessibility_id
find_elements_by_accessibility_id

 

三,Appium_Python_Client的使用

    安装完成后,要引用一下才可以使用。我们通常引用webdriver的时候是使用下面的命令的:

From selenium import webdriver

可是我们要使用appium_python_client中的函数,就要改成下面的引用方法:

From appium import webdriver

然后在setup()函数中再初始化driver如下:

self.driver=webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)

引时便可以调用appium的专用方法了!!

 

 
posted @ 2017-07-02 00:55  菜鸟学飞ing  阅读(489)  评论(0编辑  收藏  举报