#7 楼 @Edu_taluo 我不切换用的这种可以找到 xpath //android.webkit.WebView[1]/android.webkit.WebView[1]/android.widget.EditText[2]
#7 楼 @Edu_taluo 这个我打印出来没问题啊,
#5 楼 @Edu_taluo 这个是 java 吧,python 切换原理都一样,切换步骤是一样的
#1 楼 @Edu_taluo 第一次切换时成功的,第二次什么都不做或者重新切换都失败,两个界面属于 webview 的 contest 名都是一样的
@chungeguo 没有 ACCESSIBILITY_ID 属性的怎么寻找
@nancy2896 查看这篇终于发现了问题,亏我还是个开发。。。。。。
@xdf 我用的 5.1 系统,没有写 desired_caps['automationName']='Selendroid'这一句,然后切换后提示
File "./testCase/test_device.py", line 121, in test_play
self.device_add()
File "./testCase/test_device.py", line 53, in device_add
els=self.driver.find_elements_by_class_name("choose_device_btn_color")
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 425, in find_elements_by_class_name
return self.find_elements(by=By.CLASS_NAME, value=name)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 778, in find_elements
'value': value})['value']
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/appium/webdriver/errorhandler.py", line 29, in check_response
raise wde
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/appium/webdriver/errorhandler.py", line 24, in check_response
super(MobileErrorHandler, self).check_response(response)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: no such session
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.6 x86_64)
看来只能在 app 里加判断是否滑到最底部了,不知道还有其他方法没有
#47 楼 @seveniruby 请问一下 appium 有什么方法可以获取到看不见的控件,例如 listview 中需要下滑才能看见的 item,如果边下滑边判断如何判断滑到最底部
#20 楼 @weamylady 请问一下 appium 有什么方法可以获取到看不见的控件,例如 listview 中需要下滑才能看见的 item,如果边下滑边判断如何判断滑到最底部?
#2 楼 @xiaoafeizt 相当于 2 楼说的,很简单的一个 try catch
```python
一个方法,处理异常
def findElement(self, driver,id):
try:
WebDriverWait(driver, common.WAIT_TIME,1).until(driver.find_element_by_id(id))
return True
except selenium.common.exceptions.TimeoutException:
return False
except selenium.common.exceptions.NoSuchElementException:
return False
if findElement(mDriver,mId):
#找到逻辑
else:
#点击另一个
@xdf 请问一下每个测试用例都要重新安装 app 吗,这样是不是太浪费时间了,有什么办法可以解决
@harsayer 谢谢,把权限的问题解决了,然后 jdk 换成了 1.8,mac 中跑 android 成功了!
@xdf 请问一下 sudo make-test -android 发现 JAVA_HOME IS NOT SET 怎么解决。这命令前不带 sudo 没有权限
谢谢,这方面知识的确需要补一下
make-test android 我不加 sudo 的话出现 Error: EACCES: permission denied, open '/usr/local/lib/node_modules/.macaca-cli_npminstall/node_modules/.1.0.67@webdriver-server/logs/digest-2016_10_28.log'
at Error (native),加 sudo 的话又找不到 java。。。。。。
脚本我没改,设备是连上的,我是在 mac 测 android 的,win7 行不?另外的确我带了 sudo 就提示 not set,但是运行 java --version 有结果的
mac 平台,仅仅跑样例
-bash-3.2$ sudo make test-android
Password:
macaca doctor
macaca-doctor version: 1.0.23
Node.js checklist:
node env: /usr/local/bin/node
node version: v6.9.1
iOS checklist:
Xcode is installed at: /Applications/Xcode.app/Contents/Developer
Xcode Command Line Tools is ready, version: 2343.
Command Line Tools: ios_webkit_debug_proxy is uninstalled
Android checklist:
JAVA version is 1.7.0_79
JAVA_HOME is not set
ANDROID_HOME is not set
Installed driver list:
android: 1.0.39
platform=android macaca run --verbose -d ./macaca-test/macaca-mobile-sample.test.js
port: 3456 was occupied, changed port: 3457
index.js:17:12 [master] pid:2911 webdriver server start with config:
{ port: 3457,
verbose: false,
always: true,
window: true,
ip: '192.168.55.102',
host: 'miningdeiMac-4.local',
loaded_time: '2016-10-28 15:13:20' }
middlewares.js:17:10 [master] pid:2911 base middlewares attached
router.js:129:10 [master] pid:2911 router set
webdriver sdk launchedmacaca mobile sample
1) "before all" hook
2) "after all" hook
0 passing (1s)
2 failing
1) macaca mobile sample "before all" hook:
[init({"autoAcceptAlerts":true,"platformName":"Android","app":"/Users/mining/macaca-test-sample/app/android-app-bootstrap.zip"})] connect ECONNREFUSED 211.139.136.73:3457
Error: connect ECONNREFUSED 211.139.136.73:3457
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect as oncomplete2) macaca mobile sample "after all" hook:
[quit()] connect ECONNREFUSED 211.139.136.73:3457
Error: connect ECONNREFUSED 211.139.136.73:3457
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect as oncomplete
我运行 sudo make test-android 时提示我 JAVA_HOME is not set
ANDROID_HOME is not set
什么原因
bash-3.2$ macaca doctor
macaca-doctor version: 1.0.23
Node.js checklist:
node env: /usr/local/bin/node
node version: v6.9.1
iOS checklist:
Xcode is installed at: /Applications/Xcode.app/Contents/Developer
Xcode Command Line Tools is ready, version: 2343.
Command Line Tools: ios_webkit_debug_proxy is uninstalled
Android checklist:
JAVA version is 1.7.0_79
JAVA_HOME is set to /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
ANDROID_HOME is set to /Users/mining/Downloads/sdk
Platforms is set to /Users/mining/Downloads/sdk/platforms/android-24
Android tools is set to /Users/mining/Downloads/sdk/tools/android
ADB tool is set to /Users/mining/Downloads/sdk/platform-tools/adb
Installed driver list:
android: 1.0.39
1) macaca mobile sample "before all" hook:
[init({"autoAcceptAlerts":true,"platformName":"Android","app":"/Users/mining/macaca-test-sample/app/android-app-bootstrap.zip"})] connect ECONNREFUSED 211.139.136.73:3457
Error: connect ECONNREFUSED 211.139.136.73:3457
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect as oncomplete
2) macaca mobile sample "after all" hook:
[quit()] connect ECONNREFUSED 211.139.136.73:3457
Error: connect ECONNREFUSED 211.139.136.73:3457
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect as oncomplete
这个问题如何解决?
1) macaca mobile sample "before all" hook:
[init({"autoAcceptAlerts":true,"platformName":"Android","app":"/Users/mining/macaca-test-sample/app/android-app-bootstrap.zip"})] connect ECONNREFUSED 211.139.136.73:3456
Error: connect ECONNREFUSED 211.139.136.73:3456
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect as oncomplete
android 初始化的时候连接不上,怎么解决呢
1) macaca mobile sample "before all" hook:
[init({"autoAcceptAlerts":true,"platformName":"Android","app":"/Users/mining/macaca-test-sample/app/android-app-bootstrap.zip"})] connect ECONNREFUSED 211.139.136.73:3456
Error: connect ECONNREFUSED 211.139.136.73:3456
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect as oncomplete
android 也遇到了这种,什么情况