截图对比可以考虑一下性能问题,比如我要批量对比~
不错的项目,把 adb 常用的东西封装了一下,学习编程语言半年的时间内能够整理出来这个东西,充分说明楼主很务实。
拿 expected_conditions 中的 presence_of_element_located 举例来说
webdriver.support 中的 expected_conditions 中定义的该可调用类中直接调用的就是核心的 find_element 方法
而 AppiumDriver 定义的那些 Find 方法调用的正是这个核心方法,只不过他扩展了 By 类,所以,这边是可以通过访问 MobileBy 的相关属性来实现 smartwait 的
class presence_of_all_elements_located(object):
""" An expectation for checking that there is at least one element present
on a web page.
locator is used to find the element
returns the list of WebElements once they are located
"""
def __init__(self, locator):
self.locator = locator
def __call__(self, driver):
return _find_elements(driver, self.locator)
def _find_elements(driver, by):
try :
return driver.find_elements(*by)
except WebDriverException as e:
raise e
之前我在源码剖析帖里就有提及
mobileby 类扩展了之前的 By 类。
#!/usr/bin/env python
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from selenium.webdriver.common.by import By
class MobileBy(By):
IOS_UIAUTOMATION = '-ios uiautomation'
ANDROID_UIAUTOMATOR = '-android uiautomator'
ACCESSIBILITY_ID = 'accessibility id'
你这个问题最好描述的清楚一下,我怎么感觉问题不是在 index 上,index 是一个动态值,你最后的报错是说找不到这个元素,不是说 attribute 错误
个人建议:1. 你直接手动安装一下这个 APK,APK 损坏也会出现这样的情况。2. python 写 windows 的路径的时候保持一个好习惯,要么写一个 lambda 返回 abspath,要么你自行转义一下,像这种写法"F:/source/APK/fruit/fruitSwitch_sc.apk" 很危险。。。。
#4 楼 @yangyajie_002 通信机制是?
这个问题的核心要看,这两个 APP 之间是怎么互动?@monkey
PO 主无耻啊。。。
#11 楼 @umbrella1978 我们欢迎猛插。。。@monkey