qt4a.andrcontrols
Package¶
定义Android控件
-
class
qt4a.andrcontrols.
AbsListView
(*args, **kwds)¶ 基类:
qt4a.andrcontrols.ScrollView
ListView和GridView基类
-
get_child
(idx)¶ 提供使用索引访问子元素的方法
-
reach_bottom
¶ 滑动区域达到底部
-
reach_top
¶ 滑动区域达到顶部
-
reached_bottom
¶ 滑动区域达到底部
-
reached_top
¶ 滑动区域达到顶部
-
scroll_down_one_page
()¶ 向下滑动一页
-
scroll_up_one_page
()¶ 向上滑动一页
-
wait_for_complete
(timeout=2)¶ 等待ListView控件变化,比如需要读取本地数据
-
-
class
qt4a.andrcontrols.
ActionMenuItemView
(activity, root, driver, locator=None, hashcode=0)¶
-
class
qt4a.andrcontrols.
AppCompatEditText
(activity, root, driver, locator=None, hashcode=0)¶
-
class
qt4a.andrcontrols.
AppCompatImageView
(activity, root, driver, locator=None, hashcode=0)¶
-
class
qt4a.andrcontrols.
Button
(activity, root, driver, locator=None, hashcode=0)¶ -
按钮类
-
class
qt4a.andrcontrols.
CheckBox
(activity, root, driver, locator=None, hashcode=0)¶ 基类:
qt4a.andrcontrols.CompoundButton
选择按钮
-
class
qt4a.andrcontrols.
CheckedTextView
(activity, root, driver, locator=None, hashcode=0)¶ -
可选文本框
-
checked
¶ 是否已选
-
-
class
qt4a.andrcontrols.
ChromiumWebView
(url=None, title=None, *args, **kwargs)¶ 基类:
qt4a.andrcontrols.WebkitWebView
Chromium内核的WebView
-
convert_frame_tree
(frame_tree, parent=None)¶ 将frame tree转化为Frame对象
-
create_socket
()¶ 创建socket对象
-
eval_script
(frame_xpaths, script)¶ 在指定frame中执行JavaScript,并返回执行结果
参数: - frame_xpaths (list) – frame元素的XPATH路径,如果是顶层页面,怎传入“[]”
- script (string) – 要执行的JavaScript语句
-
get_debugger
(timeout=10)¶ 获取当前页面的RemoteDebugger实例
-
get_page_url
()¶ 获取当前WebView页面的url
-
-
class
qt4a.andrcontrols.
CompoundButton
(activity, root, driver, locator=None, hashcode=0)¶ -
可选按钮,一般用于实现Switch
-
class
qt4a.andrcontrols.
DatePicker
(activity, root, driver, locator=None, hashcode=0)¶ 基类:
qt4a.andrcontrols.FrameLayout
时间选择器
-
class
qt4a.andrcontrols.
DropdownView
(activity, root, driver, locator=None, hashcode=0)¶
-
class
qt4a.andrcontrols.
EditText
(activity, root, driver, locator=None, hashcode=0)¶ -
输入文本框
-
click
()¶ click后自动关闭输入法
-
send_text
(text)¶ 输入按键,此方法不能输入中文和大写字母
-
-
class
qt4a.andrcontrols.
FrameLayout
(activity, root, driver, locator=None, hashcode=0)¶
-
class
qt4a.andrcontrols.
Gravity
(grav)¶ 基类:
object
用于控制控件靠左、居中等位置的属性
-
class
qt4a.andrcontrols.
GridView
(*args, **kwds)¶ 基类:
qt4a.andrcontrols.AbsListView
格子视图
-
class
qt4a.andrcontrols.
ImageButton
(activity, root, driver, locator=None, hashcode=0)¶
-
class
qt4a.andrcontrols.
ImageView
(activity, root, driver, locator=None, hashcode=0)¶ -
显示图片控件
-
capture
(save_path='')¶ 保存图片到本地
-
save
(save_path='')¶ 保存图片到本地 to de deleted
-
-
class
qt4a.andrcontrols.
LinearLayout
(activity, root, driver, locator=None, hashcode=0)¶
-
class
qt4a.andrcontrols.
ListItem
(view, idx=None)¶ -
为方便遍历AbsListView,表示AbsListView的直接子孩子
-
has
(key)¶ 是否存在该节点
参数: key (string) – 封装时定义的子节点名
-
-
class
qt4a.andrcontrols.
ListView
(*args, **kwds)¶ 基类:
qt4a.andrcontrols.AbsListView
列表视图
-
class
qt4a.andrcontrols.
ProgressBar
(activity, root, driver, locator=None, hashcode=0)¶ -
进度条
-
progress
¶ 进度
-
-
class
qt4a.andrcontrols.
RadioButton
(activity, root, driver, locator=None, hashcode=0)¶ 基类:
qt4a.andrcontrols.CompoundButton
单选按钮
-
class
qt4a.andrcontrols.
RadioGroup
(activity, root, driver, locator=None, hashcode=0)¶
-
class
qt4a.andrcontrols.
RecyclerView
(*args, **kwds)¶ 基类:
qt4a.andrcontrols.AbsListView
虽然不是继承自ListView,但是可以复用其部分代码,所以从ListView继承过来
-
get_child
(idx)¶ 提供使用索引访问子元素的方法
-
reached_left
¶ 滑动区域达到最左边
-
reached_right
¶ 滑动区域达到最右边
-
scroll_down_one_page
()¶ 向下滑动一页
-
scroll_left_one_page
()¶ 向左滑动一页
-
scroll_right_one_page
()¶ 向右滑动一页
-
scroll_up_one_page
()¶ 向上滑动一页
-
-
class
qt4a.andrcontrols.
RelativeLayout
(activity, root, driver, locator=None, hashcode=0)¶ 基类:
qt4a.andrcontrols.ViewGroup
-
gravity
¶ 位置属性
-
-
class
qt4a.andrcontrols.
ScrollView
(activity, root, driver, locator=None, hashcode=0)¶ 基类:
qt4a.andrcontrols.FrameLayout
滚动视图
-
pull_down_refresh
()¶ 下拉刷新
-
reach_bottom
¶ 滑动区域达到底部
-
reach_top
¶ 滑动区域达到顶部
-
scroll
(x, y, count=5, interval=0.04)¶ 横向或纵向滚动
参数: - x (int) – x > 0 时向左滑动,x = x1 - x2,滚动条向右
- y (int) – y > 0时向上滑动,y = y1 - y2,滚动条向下
- count (int) – 分为几次滑动
-
scroll_down_one_page
()¶ 向下滑动一页
-
scroll_to_bottom
()¶ 滑动到底部
-
scroll_to_top
()¶ 滑动到顶部
-
scroll_up_one_page
()¶ 向上滑动一页
-
-
class
qt4a.andrcontrols.
SeekBar
(activity, root, driver, locator=None, hashcode=0)¶ 基类:
qt4a.andrcontrols.ProgressBar
可修改进度的进度条
-
progress
¶ 进度
-
-
class
qt4a.andrcontrols.
TabWidget
(activity, root, driver, locator=None, hashcode=0)¶ -
Tab控件
-
selected_index
¶ 当前所选项的索引
-
-
class
qt4a.andrcontrols.
TextView
(activity, root, driver, locator=None, hashcode=0)¶ -
包含Text的View
-
click_clickable_span
()¶ 点击TextView中的ClickableSpan区域
-
hint_text
¶ 空白提示文本
-
html_style_text
¶ HTML格式文本
-
image_resource_name
¶ 图像资源名称
-
text_color
¶ 字体颜色
-
text_size
¶ 字体大小
-
-
class
qt4a.andrcontrols.
VerticalSwipe
(view)¶ 基类:
object
纵向滑动包装类
-
rect
¶ left, top, width, height
-
swipe_down
()¶ 向下滑动
-
swipe_up
()¶ 向上滑动
-
-
class
qt4a.andrcontrols.
View
(activity, root, driver, locator=None, hashcode=0)¶ 基类:
object
控件基类
-
clickable
¶ 是否可点击 to be deleted
-
container
¶ 获取所在容器类
-
content_desc
¶ 控件描述
-
double_click
(x_offset=0, y_offset=0)¶ 双击
参数: - x_offset (int或float) – 距离控件区域左上角的横向偏移。
- y_offset (int或float) – 距离控件区域左上角的纵向偏移。
-
exist
()¶ 判断控件是否存在
-
get_metis_view
()¶ 返回MetisView
-
hashcode
¶ 控件唯一标识,只有真正访问控件信息时才会去获取该标识
-
multiple_click
(count=3, x_offset=0, y_offset=0)¶ 多次点击
参数: - count (int) – 点击多少次
- x_offset (int或float) – 距离控件区域左上角的横向偏移。
- y_offset (int或float) – 距离控件区域左上角的纵向偏移。
-
scroll_to_visible
(root_rect=None, self_rect=None)¶ 滚动到可视区域
-
swipe
(direct)¶ 滑动
参数: direct (string,只能是“up”、“down”、“left”、“right”中的一个值) – 方向
-
wait_for_exist
(timeout=10, interval=0.1)¶ 等待控件出现
-
wait_for_invisible
(timeout=10, interval=0.2)¶ 等待控件不可见
参数: - timeout (int/float) – 超时时间,单位:秒
- interval (int/float) – 重试间隔时间,单位:秒
-
wait_for_value
(prop_name, prop_value, timeout=10, interval=0.5, regularMatch=False)¶ 等待控件属性值出现, 如果属性为字符串类型,则使用正则匹配
参数: - prop_name – 属性名字
- prop_value – 等待出现的属性值
- timeout – 超时秒数, 默认为10
- interval – 等待间隔,默认为0.5
- regularMatch – 参数 property_name和waited_value是否采用正则表达式的比较。默认为不采用(False)正则,而是采用恒等比较。
-
wait_for_visible
(timeout=10, interval=0.2)¶ 等待控件可见
参数: - timeout (int/float) – 超时时间,单位:秒
- interval (int/float) – 重试间隔时间,单位:秒
-
-
class
qt4a.andrcontrols.
ViewGroup
(activity, root, driver, locator=None, hashcode=0)¶
-
class
qt4a.andrcontrols.
ViewPager
(activity, root, driver, locator=None, hashcode=0)¶ 基类:
qt4a.andrcontrols.ViewGroup
横向滚动视图
-
current_item_index
¶ 当前显示项的索引
-
item_count
¶ 总项数
-
scroll
(count=1, rect=None)¶ 左右滚动
参数: count (int) – 滑动次数,大于0表示向右滑动,小于0表示向左滑动
-
-
class
qt4a.andrcontrols.
WebView
(*args, **kwargs)¶ -
Web页面容器
-
click
(x_offset=None, y_offset=None)¶ 点击WebView中的某个坐标
参数: - x_offset (int/float) – 与WebView左上角的横向偏移量
- y_offset (int/float) – 与WebView左上角的纵向偏移量
-
disable_soft_input
()¶ 禁用软键盘
-
drag
(x1, y1, x2, y2)¶ 从(x1, y1)点滑动到(x2, y2)点
参数: - x1 (int/float) – 起点横坐标
- y1 (int/float) – 起点纵坐标
- x2 (int/float) – 终点横坐标
- y2 (int/float) – 终点纵坐标
-
eval_script
(frame_xpaths, script)¶ 在指定frame中执行JavaScript,并返回执行结果(该实现需要处理js基础库未注入情况的处理)
参数: - frame_xpaths (list) – frame元素的XPATH路径,如果是顶层页面,怎传入“[]”
- script (string) – 要执行的JavaScript语句
-
long_click
(x_offset, y_offset, duration=1)¶ 长按WebView中的某个坐标
参数: - x_offset (int/float) – 与WebView左上角的横向偏移量
- y_offset (int/float) – 与WebView左上角的纵向偏移量
- duration (int/float) – 按住的持续时间
-
screenshot
()¶ 当前WebView的截图 :return: PIL.Image
-
send_keys
(keys)¶ 向WebView中的输入框发送按键
参数: keys (string) – 要发送的按键
-
visible_rect
¶ WebView控件可见区域的坐标信息
-
webdriver_class
¶ WebView对应的WebDriver类
-
webview_impl
¶
-
-
class
qt4a.andrcontrols.
WebkitWebView
(*args, **kwargs)¶ -
4.4以下版本中的WebView
-
eval_script
(frame_xpaths, script)¶ 执行JavaScript
-
-
class
qt4a.andrcontrols.
Window
(app_or_driver, wait_activity=True, **kwds)¶ 基类:
object
控件容器基类
-
Controls
¶ 返回控件集合。使用如foo.Controls[‘最小化按钮’]的形式获取控件
-
get_metis_view
()¶ 返回MetisView
-
hasControlKey
(control_key)¶ 是否包含控件control_key
返回类型: boolean
-
post_init
()¶ 窗口类自定义的初始化逻辑
-
update_locator
(locators)¶ 更新控件定义
-
wait_for_exist
(timeout=10, interval=0.5)¶ 等待窗口出现
-
-
qt4a.andrcontrols.
func_wrap
(func)¶ 用于方法包装,主要作用是发现控件失效时能够更新控件
-
qt4a.andrcontrols.
lazy_init
(func)¶ 调用到此函数时进入延迟初始化逻辑