新手學appium-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的專用方法了!!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM