Appium Appium python 框架

tongshanshanshan · October 12, 2015 · Last by 水乡人 replied at June 04, 2019 · 10746 hits
本帖已被设为精华帖!

希望给点意见和建议,毕竟周围没有人可以交流。。。

前言

嘿嘿,第一次发帖有点小激动。
接触appium也有一个多月了,自己根据以前做selenium的经验(其实只有一年不到!!!)搭建了框架,希望大家给点意见啊!!!毕竟我身边没有可以和我交流的!!!万分感谢

流程

1.打开appium server
2.获取当前手机的device Name 和 安卓版本号,打开driver
3.运行case
4.生成报告
5.关闭driver
6.关闭appium server

结构

具体说说run.py

整个程序是从这个模块开始运行的,也是花了我最长时间的地方。下面上代码

# ========================================================
# Summary :run
# Author :tong shan
# Create Date :2015-10-09
# Amend History :
# Amended by :
# ========================================================

import readConfig
readConfigLocal = readConfig.ReadConfig()
import unittest
from testSet.common.DRIVER import myDriver
import testSet.common.Log as Log
import os
from time import sleep

from selenium.common.exceptions import WebDriverException
import threading

mylock = threading.RLock()
log = Log.myLog.getLog()

# ========================================================
# Summary :myServer
# Author :tong shan
# Create Date :2015-10-10
# Amend History :
# Amended by :
# ========================================================
class myServer(threading.Thread):

def __init__(self):
global appiumPath
threading.Thread.__init__(self)
self.appiumPath = readConfigLocal.getConfigValue("appiumPath")

def run(self):

log.outputLogFile("start appium server")
rootDirectory = self.appiumPath[:2]
startCMD = "node node_modules\\appium\\bin\\appium.js"

#cd root directory ;cd appiuu path; start server
os.system(rootDirectory+"&"+"cd "+self.appiumPath+"&"+startCMD)

# ========================================================
# Summary :Alltest
# Author :tong shan
# Create Date :2015-10-10
# Amend History :
# Amended by :
# ========================================================
class Alltest(threading.Thread):

def __init__(self):
threading.Thread.__init__(self)
global casePath, caseListLpath, caseList, suiteList, appiumPath
self.caseListPath = readConfig.logDir+"\\caseList.txt"
self.casePath = readConfig.logDir+"\\testSet\\"
self.caseList = []
self.suiteList = []
self.appiumPath = readConfigLocal.getConfigValue("appiumPath")

# =================================================================
# Function Name : driverOn
# Function : open the driver
# Input Parameters: -
# Return Value : -
# =================================================================
def driverOn(self):
myDriver.GetDriver()

# =================================================================
# Function Name : driverOff
# Function : colse the driver
# Input Parameters: -
# Return Value : -
# =================================================================
def driverOff(self):
myDriver.GetDriver().quit()

# =================================================================
# Function Name : setCaseList
# Function : read caseList.txt and set caseList
# Input Parameters: -
# Return Value : -
# =================================================================
def setCaseList(self):

print(self.caseListPath)

fp = open(self.caseListPath)

for data in fp.readlines():

sData = str(data)
if sData != '' and not sData.startswith("#"):
self.caseList.append(sData)

# =================================================================
# Function Name : createSuite
# Function : get testCase in caseList
# Input Parameters: -
# Return Value : testSuite
# =================================================================
def createSuite(self):

self.setCaseList()
testSuite = unittest.TestSuite()

if len(self.caseList) > 0:

for caseName in self.caseList:

discover = unittest.defaultTestLoader.discover(self.casePath, pattern=caseName+'.py', top_level_dir=None)
self.suiteList.append(discover)

if len(self.suiteList) > 0:

for test_suite in self.suiteList:
for casename in test_suite:
testSuite.addTest(casename)
else:
return None

return testSuite

# =================================================================
# Function Name : runTest
# Function : run test
# Input Parameters: -
# Return Value : -
# =================================================================
def run(self):

try:


while not isStartServer():
mylock.acquire()
sleep(1)
log.outputLogFile("wait 1s to start appium server")
mylock.release()
else:
log.outputLogFile("start appium server success")
suit = self.createSuite()
if suit != None:

log.outputLogFile("open Driver")
self.driverOn()
log.outputLogFile("Start to test")
unittest.TextTestRunner(verbosity=2).run(suit)
log.outputLogFile("end to test")
log.outputLogFile("close to Driver")
self.driverOff()

else:
log.outputLogFile("Have no test to run")
except Exception as ex:
log.outputError(myDriver.GetDriver(), str(ex))

def isStartServer():

try:
driver = myDriver.GetDriver()
if driver == None:
return False
else:
return True
except WebDriverException:
raise


if __name__ == '__main__':

thread1 = myServer()
thread2 = Alltest()

thread2.start()
thread1.start()

while thread2.is_alive():
sleep(10)#"allTest is alive,sleep10"
else:
#kill myServer
os.system('taskkill /f /im node.exe')
log.outputLogFile("stop appium server")

思路

刚接触的时候发现每次都要手动打开appium 服务,然后再运行代码,想着是不是太麻烦了?就想试着可不可做成一步?
这一想,就费了我好多功夫。
1.打开appium server
开始的时候,连如何用命令行打开服务都不会,在群里问了一圈(感谢回答问题的大大们!!!),然后自己又琢磨了一下,搞定了,可是!!!用os.system(),居然阻塞进程,最后还是问了群里的大大解决(再次感谢!!!!)。
2.如何判断server是否被成功开启
这个问题我想了很久,现在我解决了,但是解决方法我不太满意,希望有大大可以给我一个好点的方法或者思路(跪谢!!)
目前做法:判断是否可以返回一个正常的driver对象

def isStartServer():

try:
driver = myDriver.GetDriver()
if driver == None:
return False
else:
return True
except WebDriverException:
raise

3.关闭appium server
目前的做法是强制杀死,还是不太满意,不知道以后会不会有什么不可预见的问题,希望有大大可以给我一个好点的方法或者思路(跪谢!!)

if __name__ == '__main__':

thread1 = myServer()
thread2 = Alltest()

thread2.start()
thread1.start()

while thread2.is_alive():
sleep(10)#"allTest is alive,sleep10"
else:
#kill myServer
os.system('taskkill /f /im node.exe')
log.outputLogFile("stop appium server")

其他模块

1.common.py 共同方法,主要指封装了一些方法,供其他模块使用。
2.DRIVER.py获取driver,这里是做成了一个单例模式,run.py中打开,关闭,其他模块调用。
3.Log.py中有2个类log和myLog,同样也把myLog做成了一个单例模式
4.myPhone.py主要使用了adb命令来识别和获取手机参数
5.readConfig.py是读取配置文件

有点遗憾的地方

1.目前异常机制还不够完善,也怪我学艺不精
2.线程是先学的,线程安全之类也没有考虑,目前做到的仅仅是可以用了
3.测试数据参数化还没有实现(这个还要再研究)
4.重要的话说3遍:没有人交流!!!
没有人交流!!!
没有人交流!!!
希望大家在看完后,多多题意见

最后附上源码地址:https://github.com/tongshan1/appium_python

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 109 条回复 时间 点赞

在第2点中,判断appium是否开启,我使用的是http get 这个url: http://127.0.0.1:4723/wd/hub/status ,可以获取到appium的状态,如果在执行中,还可以得到正在执行的手机的udid等信息。

第3点钟,杀进程没关系,不放心可以在案例的最后 delete session。

#2楼 @among29 谢谢回复,我会试试的。

@tongshanshanshan testerhome欢迎你。

先点赞!

结构很nice~~学习了

#2楼 @among29

第一点根据你提供的方法我写出来了

def isStartServer():

response = None
url = baseUrl+"/status"
try:
response = urllib.request.urlopen(url, timeout=5)

if str(response.getcode()).startswith("2"):
print(response.getcode())
return True
else:
return False
except URLError:
return False
finally:
if response:
response.close()

第二点

我发现在case执行结束后有这么一句log
info: <-- DELETE /wd/hub/session/ebfae3a8-b604-47c1-bb58-17cf02b28b57 200 977.879 ms - 76 {"status":0,"value":null,"sessionId":"ebfae3a8-b604-47c1-bb58-17cf02b28b57"}
是不是意味着我不需要在delete session了呢?

先github star 一下再说

appium初学者,想问一下,在安装appium除了错误: 请问如何破解
C:\Users\Administrator\AppData\Roaming\npm\node_modules\appium\node_modules\ws\node_modules\bufferutil\build\b inding.sln : error MSB3411: 未能加载 Visual C++ 组件“VCBuild.exe”。如果未安装该组件,请执行下列操作之一: 1) 安
装 Microsoft Windows SDK fo
r Windows Server 2008 和 .NET Framework 3.5;或 2) 安装 Microsoft Visual Studio 2008。

很好的框架,也是我想要找到和学习的东西,新人学艺不精,先收藏,慢慢学习!

#11楼 @wusuowei
请安装VC++运行包或者VS 2010以上版本,应该可以解决。

#9楼 @tongshanshanshan 判断返回值是不是200,是一种方式,返回的json数据里面有 status等字段,也可以判断。
正常情况下,driver的close_app ,quit方法也会delete session,不用手动操作。

赞一个!

这么短时间能做到这个程度很不错了,框架的层次基本已经出来了。

下面是一些个人的建议:

  1. 既然分层了,那就尽量不要把所有执行相关的文件都放到 run.py 里面,按照层次分离成不同的文件。这样更清晰,也方便未来扩展(我估计很快你就需要扩展各个层次的内容了,各层次的功能不是很够用)
  2. appium server wrapper 这方面你可以参考下 cosyman 以前发过的帖子。他写的比较全。server 建议用进程做。
  3. 不是很理解为何要设计成运行测试和 server 要做成两个 thread 。个人觉得应该 server 是一个 process ,wrapper 提供 start 和 stop 方法,然后框架就直接 run 就好了。 run 完后调用 wrapper 的 stop 就没问题了,没啥必要做个轮询不断地检查 run 完没。
  4. 其实 appium server 还是比较稳定的,不至于会经常挂掉,所以个人觉得没太大必要在测试框架里总是去打开/关闭它,把它当 service ,启动后一直运行就好了。

接下来是个人代码洁癖给出的吐槽,不想打击你,但忍不住要吐下槽:

  1. 一处 open file 后不 close 。建议如果没办法记得去 close 的话用 with open(path, mode) as f 来打开文件。
  2. 代码风格有点偏 Java (主要是注释的使用),建议你看下 python-client 的源码和 Google 的 Python风格规范,代码风格和主流贴近一点,这样便于让别人阅读你的代码,进而和你合作。
  3. 从代码来看你的两个线程之间没什么资源共享,应该不需要搞线程锁什么的。不过我对线程也不是十分熟悉,你还是先看下相关资料再决定吧。
  4. 路径建议用 os.path.join ,不要把路径分隔符 hard code 进去。
  5. log 的方法名越短越好,最好 log.d, log.i 之类的就好了。另外, python 有现成的 logging 模块,功能强大,没太大必要自己实现个 Log 模块。

#16楼 @chenhengjie123 恒洁有架构师的风范啊

#16楼 @chenhengjie123 十分感谢,我会努力改善的!!

一样,我也是来这里看下大家有什么好的想法,不过我们用的java,因为感觉testNG用的还挺爽,就用的飞起了,哈哈。其实感觉可以把所有控件做成单一一个文件之类的也是不错的方法

#16楼 @chenhengjie123 @tongshanshanshan 嗯,恒洁架构师风范啊。
appium server确实就用线程做是比较好的了。
然后线程锁的话你能实现出来肯定是最好的,有用的地方还是有的。
场景总会遇到,比如:
短时间内的并发,用线程锁去处理端口、设备号的分配更加安全。
不然用get http status的方式的话,中间总会有启动Appium或其他方面的耗时,导致端口冲突的问题。

#20楼 @darker50 好的,我会试试的。谢谢你的意见

#21楼 @anikikun 谢谢你的意见,我会试试的。

#17楼 @lihuazhang
#18楼 @monkey
#21楼 @anikikun
我那只是代码洁癖,和架构师还有很大差距。。。现在深入了解过架构的程序还不够多,很多想法还很 native 。。。

#19楼 @tongshanshanshan 继续加油!以后多点过来 Testerhome 交流, sharing codes show cool

hi 大师 ,我碰到了一个问题,可否给些意见?我用的app 是混合型app,web开发通过angular js,当用appium 的时候找不到pop
view 的元素,如截图中弹出来的pick a doctor 界面上的元素cancel 就是找不到。 这个是要怎么解决呢?。server log 如下:
Tests-MacBook-Pro-2:python testuser$ python /Users/testuser/Desktop/Appium\ Example/sample-code/sample-code/examples/python/android_AuroraMakeappointment.py
test_webview (main.AndroidWebViewTests) ... info: --> POST /wd/hub/session {"desiredCapabilities":{"platformVersion":"4.4","appPackage":"com.covidien.rpm","app":"/Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk","platformName":"Android","deviceName":"SM-T331C"}}
info: Client User-Agent string: Python-urllib/2.7
info: [debug] No appActivity desired capability or server param. Parsing from apk.
info: [debug] Using local app from desired caps: /Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk
info: [debug] Creating new appium session e2cefc8e-48a5-488c-ac58-d24da9e8d744
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.7.0_79
info: [debug] Checking whether adb is present
info: [debug] Using adb from /users/testuser/Library/Android/sdk/platform-tools/adb
info: [debug] Parsing package and activity from app manifest
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from /users/testuser/Library/Android/sdk/build-tools/22.0.1/aapt
info: [debug] Extracting package and launch activity from manifest.
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/build-tools/22.0.1/aapt dump badging "/Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk"
info: [debug] badging package: com.covidien.rpm
info: [debug] badging act: com.covidien.rpm.activity.MainWebActivity
info: [debug] Parsed package and activity are: com.covidien.rpm/com.covidien.rpm.activity.MainWebActivity
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb devices
info: [debug] 1 device(s) connected
info: Found device a4aa956805cd2952
info: [debug] Setting device id to a4aa956805cd2952
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 wait-for-device
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: Device API level is: 19
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "getprop persist.sys.language"
info: [debug] Current device persist.sys.language: en
info: [debug] java -jar "/usr/local/lib/node_modules/appium/node_modules/appium-adb/jars/appium_apk_tools.jar" "stringsFromApk" "/Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk" "/tmp/com.covidien.rpm" en
info: [debug] No strings.xml for language 'en', getting default strings.xml
info: [debug] java -jar "/usr/local/lib/node_modules/appium/node_modules/appium-adb/jars/appium_apk_tools.jar" "stringsFromApk" "/Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk" "/tmp/com.covidien.rpm"
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 push "/tmp/com.covidien.rpm/strings.json" /data/local/tmp
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from /users/testuser/Library/Android/sdk/build-tools/22.0.1/aapt
info: [debug] Retrieving process from manifest.
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/build-tools/22.0.1/aapt dump xmltree "/Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk" AndroidManifest.xml
info: [debug] Set app process to: com.covidien.rpm
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for /Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk.
info: [debug] executing cmd: java -jar /usr/local/lib/node_modules/appium/node_modules/appium-adb/jars/verify.jar "/Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk"
info: [debug] App already signed.
info: [debug] Zip-aligning /Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from /users/testuser/Library/Android/sdk/build-tools/22.0.1/zipalign
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/build-tools/22.0.1/zipalign -f 4 "/Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk" /var/folders/7p/vc6l_9b12rl7f6k4xrx44wxm0000gn/T/115914-9413-fsi6k8/appium.tmp
info: [debug] MD5 for app is ac0eb8b8d4482d7c3b6d5a7feb3db4ed
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "ls /data/local/tmp/ac0eb8b8d4482d7c3b6d5a7feb3db4ed.apk"
info: [debug] Getting install status for com.covidien.rpm
info: [debug] Getting device API level
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "pm list packages -3 com.covidien.rpm"
info: [debug] App is installed
info: Installing App
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "mkdir -p /data/local/tmp/"
info: [debug] Removing any old apks
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "ls /data/local/tmp/*.apk"
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell rm "/data/local/tmp/29649242b53e9a67ba855b067422713c.apk"
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 push "/Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk" /data/local/tmp/ac0eb8b8d4482d7c3b6d5a7feb3db4ed.apk
info: [debug] Uninstalling com.covidien.rpm
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "am force-stop com.covidien.rpm"
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 uninstall com.covidien.rpm
info: [debug] App was uninstalled
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "pm install -r /data/local/tmp/ac0eb8b8d4482d7c3b6d5a7feb3db4ed.apk"
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device...
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 push "/usr/local/lib/node_modules/appium/build/android_bootstrap/AppiumBootstrap.jar" /data/local/tmp/
info: [debug] Pushing settings apk to device...
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 install "/usr/local/lib/node_modules/appium/build/settings_apk/settings_apk-debug.apk"
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 install "/usr/local/lib/node_modules/appium/build/unlock_apk/unlock_apk-debug.apk"
info: Starting App
info: [debug] Attempting to kill all 'uiautomator' processes
info: [debug] Getting all processes with 'uiautomator'
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "ps 'uiautomator'"
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.covidien.rpm -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json...
info: [debug] Waking up device if it's not alive
info: [debug] Pushing command to appium work queue: ["wake",{}]
info: [debug] [BOOTSTRAP] [debug] json loading complete.
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: wake
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "dumpsys window"
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: ["getDataDir",{}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"\/data\/local\/tmp","status":0}
info: [debug] dataDir set to: /data/local/tmp
info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":false,"status":0}
info: [debug] Getting device API level
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.covidien.rpm/com.covidien.rpm.activity.MainWebActivity"
info: [debug] Waiting for pkg "com.covidien.rpm" and activity "com.covidien.rpm.activity.MainWebActivity" to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "dumpsys window windows"
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "getprop ro.build.version.release"
info: [debug] Device is at release version 4.4.2
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 60 secs
info: [debug] Appium session started with sessionId e2cefc8e-48a5-488c-ac58-d24da9e8d744
info: <-- POST /wd/hub/session 303 22694.460 ms - 74
info: --> GET /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744 {}
info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformVersion":"4.4","appPackage":"com.covidien.rpm","app":"/Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk","platformName":"Android","deviceName":"SM-T331C"},"appPackage":"com.covidien.rpm","app":"/Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk","platformName":"Android","deviceName":"a4aa956805cd2952"},"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: <-- GET /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744 200 1.369 ms - 697 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformVersion":"4.4","appPackage":"com.covidien.rpm","app":"/Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk","platformName":"Android","deviceName":"SM-T331C"},"appPackage":"com.covidien.rpm","app":"/Users/testuser/Desktop/Appium Example/sample-code/sample-code/apps/Aurora.apk","platformName":"Android","deviceName":"a4aa956805cd2952"},"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: --> POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/elements {"using":"class name","sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744","value":"android.widget.EditText"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (1)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=1]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (2)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=2]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[{"ELEMENT":"1"},{"ELEMENT":"2"}],"status":0}
info: [debug] Responding to client with success: {"status":0,"value":[{"ELEMENT":"1"},{"ELEMENT":"2"}],"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: <-- POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/elements 200 184.366 ms - 105 {"status":0,"value":[{"ELEMENT":"1"},{"ELEMENT":"2"}],"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: --> POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element/1/value {"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744","id":"1","value":["j","i","n","g","j","i","n","g"]}
info: [debug] Pushing command to appium work queue: ["element:setText",{"elementId":"1","text":"jingjing","replace":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"1","text":"jingjing","replace":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: setText
info: [debug] [BOOTSTRAP] [debug] Using element passed in.
info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().
info: [debug] [BOOTSTRAP] [debug] Sending plain text to element: jingjing
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: <-- POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element/1/value 200 6958.115 ms - 76 {"status":0,"value":true,"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: --> POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element/2/value {"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744","id":"2","value":["1","2","3","4","5","6"]}
info: [debug] Pushing command to appium work queue: ["element:setText",{"elementId":"2","text":"123456","replace":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"2","text":"123456","replace":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: setText
info: [debug] [BOOTSTRAP] [debug] Using element passed in.
info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().
info: [debug] [BOOTSTRAP] [debug] Sending plain text to element: 123456
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: <-- POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element/2/value 200 4677.353 ms - 76 {"status":0,"value":true,"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: --> POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element {"using":"name","sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744","value":"Login"}
warn: [DEPRECATED] The name locator strategy has been deprecated and will be removed. Please use the accessibility id locator strategy instead.
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"Login","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"Login","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding Login using NAME with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=Login, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"3"},"status":0}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"3"},"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: <-- POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element 200 51.049 ms - 87 {"status":0,"value":{"ELEMENT":"3"},"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: --> POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element/3/click {"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744","id":"3"}
info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"3"}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"3"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: <-- POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element/3/click 200 128.167 ms - 76 {"status":0,"value":true,"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: --> POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element {"using":"name","sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744","value":"Make New Appointment"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"Make New Appointment","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"Make New Appointment","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding Make New Appointment using NAME with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=Make New Appointment, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"4"},"status":0}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"4"},"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: <-- POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element 200 101.800 ms - 87 {"status":0,"value":{"ELEMENT":"4"},"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: --> POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element/4/click {"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744","id":"4"}
info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"4"}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"4"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: <-- POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element/4/click 200 641.900 ms - 76 {"status":0,"value":true,"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: --> POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element {"using":"name","sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744","value":"Cancel"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"Cancel","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"Cancel","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding Cancel using NAME with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=Cancel, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=Cancel, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding Cancel using NAME with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=Cancel, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=Cancel, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"No element found","status":7}
info: [debug] Condition unmet after 1119ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"No element found"},"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: <-- POST /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744/element 500 1123.018 ms - 195
ERROR
info: --> DELETE /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744 {}
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: /users/testuser/Library/Android/sdk/platform-tools/adb -s a4aa956805cd2952 shell "input keyevent 3"
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"OK, shutting down","status":0}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 27.235
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}
info: <-- DELETE /wd/hub/session/e2cefc8e-48a5-488c-ac58-d24da9e8d744 200 1131.054 ms - 76 {"status":0,"value":null,"sessionId":"e2cefc8e-48a5-488c-ac58-d24da9e8d744"}

ERROR: test_webview (main.AndroidWebViewTests)

Traceback (most recent call last):
File "/Users/testuser/Desktop/Appium Example/sample-code/sample-code/examples/python/android_AuroraMakeappointment.py", line 43, in test_webview
button2=self.driver.find_element_by_name('Cancel')
File "/Library/Python/2.7/site-packages/selenium-2.47.3-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 330, in find_element_by_name
return self.find_element(by=By.NAME, value=name)
File "/Library/Python/2.7/site-packages/selenium-2.47.3-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 712, in find_element
{'using': by, 'value': value})['value']
File "/Library/Python/2.7/site-packages/selenium-2.47.3-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "/Users/testuser/Desktop/Appium Example/sample-code/sample-code/examples/python/appium/webdriver/errorhandler.py", line 29, in check_response
raise wde
NoSuchElementException: Message: An element could not be located on the page using the given search parameters.
截图在附近

#26楼 @dujingjing1_1
1.大师我不敢当啊,我也是刚接触不久。
2.我看了一下log,你是根据find_element(by=By.NAME, value=name)来寻找的,有没有尝试过xpath之类的?弹出框的话,找之前是不是要switch_to_alert()一下呢?
3.其他的话我也想不到其他原因了,毕竟我也接触不久。不知道可不可帮到你。

这个弹出框的元素没有办法用appium 定位,所以没有xpath。这个弹出框是modal view的 ,

31Floor has been deleted
32Floor has been deleted

很棒。向你学习。

我在使用的时候报以下错误,请教一下是咋回事,感觉是没获取到case,但是不知道咋改

est01 (unittest.loader._FailedTest) ... ERROR

======================================================================
ERROR: test01 (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test01
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\unittest\loader.py", line 428, in _find_test_path
module = self._get_module_from_name(name)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\unittest\loader.py", line 369, in _get_module_from_name
__import__(name)

#34楼 @yuweixx 贴下代码呢,是不是你的路径没有配对?

#35楼 @tongshanshanshan
config.ini

appiumPath =C:\Program Files\nodejs\node_modules\appium
platformName=Android
appPackage=com.w.m
appActivity=.welcome
baseUrl=http://127.0.0.1:4723/wd/hub
findElementTimes=10

run.py

def __init__(self):
global casePath, caseListLpath, caseList, suiteList, appiumPath,log,logger
self.caseListPath = os.path.join(readConfig.prjDir, "caseList.txt")
self.casePath = os.path.join(readConfig.prjDir, "testSet\\")
self.caseList = []
self.suiteList = []
self.appiumPath = readConfigLocal.getConfigValue("appiumPath")
self.myServer = AppiumServer()
def createSuite(self):
"""from the caseList,get caseName,According to the caseName to search the testSuite
:return:testSuite
"""

self.setCaseList()
testSuite = unittest.TestSuite()

if len(self.caseList) > 0:

for caseName in self.caseList:

discover = unittest.defaultTestLoader.discover(start_dir=self.casePath, pattern=caseName+'.py', top_level_dir=None)
self.suiteList.append(discover)

文件存放的位置应该没有问题,case放在testSet下,caseList在上一级testApp下
以上的这些涉及到case路径的我也没动过。
注:我的系统是win10.

#36楼 @yuweixx 我加你qq看下?

#37楼 @tongshanshanshan 492497451,但公司上不了QQ。你的github最近还会更新吗?方便剧透一下吗?

#38楼 @yuweixx 这几个月都会更新的

这里锁没必要rlock,直接lock即可,没用在线程里面继续锁资源的需求

#40楼 @turinblueice 已经修改了,修改后的请看这个https://testerhome.com/topics/3526

希望越做越好!

@tongshanshanshan 你好楼主,方便发下QQ吗 加一下你 有几个问题

我把配置改了之后 还是提示报错。

这是我QQ加一下 281599519 最近公司在搞移动端自动化 希望帮帮忙

@tongshanshanshan 学习了,能不能在github上获取学习一哈 😄

#47楼 @spanthrive 帖子上有附github地址

可以帮我安装下APPium 安卓自动化测试环境吗

—— 来自TesterHome官方 安卓客户端

这个项目可以运行吗,为什么放在我的环境中运行报错啊

运行时,报错
/usr/bin/python /Users/haozhen/PycharmProjects/dudutest/duTestSet/run.py
Traceback (most recent call last):
File "/Users/haozhen/PycharmProjects/dudutest/duTestSet/run.py", line 9, in
from duTestSet.common.DRIVER import MyDriver
ImportError: No module named duTestSet.common.DRIVER

Process finished with exit code 1

#51楼 @dudubaby 你仔细查看一下路径是否有问题。

#52楼 @tongshanshanshan 已经ok了,是python版本的问题,之前用的python2.7然后不支持这种目录引用,后来换成python3.4就ok了,但还有其他问题,可否加下你QQ请教一下

#53楼 @dudubaby 可以再群里搜我。。。

#54楼 @tongshanshanshan 什么群哪个群,我没加群啊

你的文件里面没有phone.py可以发一下完整的代码吗,谢谢大神。我是初学者

#56楼 @mymgbaby 我删了,代码移到init.py里面了。

58Floor has been deleted

#3楼 @tongshanshanshan 为啥我直接下载你的代码运行是这样的

#59楼 @mymgbaby 看英文,英文不好,还是别学编程了。

#59楼 @mymgbaby 缺模块,安装模块

#61楼 @mymgbaby 这个错误无关紧要

#60楼 @lihuazhang 我确实有这个模块啊

我只直接下载他的代码,直接调试的

#62楼 @lihuazhang
他这个是导入自定义的模块,

#64楼 @mymgbaby common目录下新建一个init.py文件。。这种问题与测试无关,你上网百度呗

#64楼 @mymgbaby common 是不是 package?

#65楼 @neyo common下面本来就有init.py文件

#66楼 @lihuazhang common是文件夹

#67楼 @mymgbaby 那个是外层的吧,你在common文件内新建一个试试

#68楼 @mymgbaby 文件名起错了啊亲..你看看我怎么打的

#70楼 @neyo 你仔细看一下啊,内层也有一个的额

#71楼 @mymgbaby common文件夹下面没有init.py吧。。

#73楼 @mymgbaby 不好意思。。我打的被markdown加粗了😢,你看demo1.py上面那个文件名。。

#74楼 @neyo 嗯嗯,没事。

#75楼 @mymgbaby 这样ok了吗?

#76楼 @neyo 我的目录结构一直就是这样啊,就是报错找不到模块额。。。

#74楼 @neyo
#75楼 @mymgbaby common是一个文件夹,里面的init.py是我添加的,目的是在运行case之前识别手机,获取手机信息,testSet是一个package,在创建package的时候会自动创建init.py。2个是不同的,一个是系统自动创建的,一个是我自己建的。不知道我说明白来没有。还有啊,不是把代码拷贝下来就是直接能运行,里面还有一些配置是需要自己配置的。

楼主你好,我想问下就是你放在testcase的excel里面放的是测试用例代码是吧,然后在需要做测试的时候传到代码里是这个思路吧,比如login的测试用例,是什么时候传呢,比如我选择了账号框在send_keys( "")这里传测试用例吗
,不好意思可能你觉的问题很低级,但我没接触过这块,以前都是把用例写在代码里,但这样显的代码太长了太重复了,也想像你学习

楼主已疯

#79楼 @enumerate 不是,在测试开始的读取测试用例,将测试用例作为参数传入带测试的case。具体你可以看看demo2.py

#78楼 @tongshanshanshan 嗯。。我看她这边缺文件,想她是不是误删了,所以让她加一下

#79楼 @enumerate 没懂你问的啥,不过浅陋的说几句,你在前台比如说一个网站上编写好用例,并把用例的数据(用例名,用例定位方式,以及元素的值,断言啥的)存在数据库,点击调试,再把用例id传给你封装好的一些类,在后台进行以下操作:通过id查找该用例的具体信息,在去定位每个步骤的元素,最后再执行一些动作,比如点击,输入之类的。

#78楼 @tongshanshanshan 哪些配置啊?能针对我这个问题说一下吗

#82楼 @neyo 我没删他的代码额,就是他的源代码

#84楼 @mymgbaby 你现在还有什么问题?

#86楼 @tongshanshanshan 一直就是那个问题啊
找不到导入的模块

#85楼 @mymgbaby 你和楼主讨论吧。。我撤了= =

#87楼 @mymgbaby 编译通过没?

#88楼 @neyo 还是很谢谢你,试着帮我解决问题。

#89楼 @tongshanshanshan 编译也是说找不到模块

#81楼 @tongshanshanshan 好的谢谢楼主,我周六日要狂看demo2,嘿嘿

#83楼 @mymgbaby 好的多谢,我学习下楼主的demo2,然后在结合你说的自己搞一下,多谢回答

#94楼 @tongshanshanshan 直接在代码里面加?加了也没用啊

#93楼 @enumerate 你直接运行这个代码没问题吗?还是做了什么配置的?

在你的init.py 中。运行该文件,print startServer,得到的是
这个是不是有问题

#95楼 @mymgbaby 哎。。加qq聊吧。

#98楼 @tongshanshanshan 你只能通过email添加额,你的 email 是?

把github上的源码下载到本地试运行了一下,报错“No module named readConfig”,楼主知不知道是哪里出了问题呀?

tongshanshanshan [Topic was deleted] 中提及了此贴 30 Jun 16:56

新手学习了

tongshanshanshan Appium+python 框架 (二) 中提及了此贴 01 Dec 14:04

楼主,我是初来学习的。看到你写的框架,赞。
能分享一下你的源码吗,非常感谢。

楼主,源码地址失效了,可以再提供下吗?另外我运行appium的时候报错“error:Failed to start an Appium session,err was:Error:Waited 20 secs fro selendroid server and it never showed up"
app一启动马上就关闭了,有遇到过吗?

小马 python appium UI 自动化测试框架讨论 中提及了此贴 01 Feb 10:48

先点赞,楼主你的github用不了,想看下你的源码。

渣渣 · #110 · June 20, 2018
Author only

楼主,你github访问不了了

@tongshanshanshan 你的github访问不了了,正在学习appium,想看下源码。

@tongshanshanshan git地址失效了,麻烦给个~~~😀

星痕 python+selenium UI 自动化测试 中提及了此贴 01 Sep 05:00

地址失效了,想看下源码,跪求~

地址失效了 想看下yuan ma r

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up