使用pywinauto处理UI自动化,定位到了确定取消按钮,使用.click()运行没有反应
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用pywinauto处理UI自动化,定位到了确定取消按钮,使用.click()运行没有反应相关的知识,希望对你有一定的参考价值。
参考技术A
.click两次
(selenium+python)_UI自动化09_定位alert弹窗
前言
web网站中某些点击操作会触发alert弹窗。在selenium进行自动化过程中,模拟操作alert弹窗时直接定位会报错找不到元素。需要先切换到alert然后用alert处理方法进行操作。
alert常用方法
switch_to.alert # 切换到alert弹窗
text # 获取弹出框文本
accept() # 确定
dismiss() # 取消
send_keys() # 输入
实例
模拟操作alert步骤如下:
点击某按钮弹出alert-->切换到alert-->操作alert
1 driver.find_element_by_id("").click() # 点击按钮,弹出alert弹窗
2 time().sleep(3) # 等待弹出alert
3 alt = driver.switch_to.alert
4 print("alert中文本:", alt.text) # 打印alert中文本
5 alt.accept() # 点击alert弹窗-确定btn
!--5f39ae17-8c62-4a45-bc43-b32064c9388a:W3siYmxvY2tJZCI6IjU2NzYtMTU1MzU2NjQwNzY3NSIsImJsb2NrVHlwZSI6InBhcmFncmFwaCIsInN0eWxlcyI6eyJhbGlnbiI6ImxlZnQiLCJpbmRlbnQiOjAsInRleHQtaW5kZW50IjowLCJsaW5lLWhlaWdodCI6MS43NSwiYmFjay1jb2xvciI6IiIsInBhZGRpbmciOiIifSwidHlwZSI6InBhcmFncmFwaCIsInJpY2hUZXh0Ijp7ImRhdGEiOlt7ImNoYXIiOiLngrkifSx7ImNoYXIiOiLlh7sifSx7ImNoYXIiOiLmn5AifSx7ImNoYXIiOiLmjIkifSx7ImNoYXIiOiLpkq4ifSx7ImNoYXIiOiLlvLkifSx7ImNoYXIiOiLlh7oifSx7ImNoYXIiOiJhIn0seyJjaGFyIjoibCJ9LHsiY2hhciI6ImUifSx7ImNoYXIiOiJyIn0seyJjaGFyIjoidCJ9LHsiY2hhciI6Ii0ifSx7ImNoYXIiOiItIn0seyJjaGFyIjoiPiJ9LHsiY2hhciI6IuWIhyJ9LHsiY2hhciI6IuaNoiJ9LHsiY2hhciI6IuWIsCJ9LHsiY2hhciI6ImEifSx7ImNoYXIiOiJsIn0seyJjaGFyIjoiZSJ9LHsiY2hhciI6InIifSx7ImNoYXIiOiJ0In0seyJjaGFyIjoiLSJ9LHsiY2hhciI6Ii0ifSx7ImNoYXIiOiI+In0seyJjaGFyIjoi5omTIn0seyJjaGFyIjoi5Y2wIn0seyJjaGFyIjoiYSJ9LHsiY2hhciI6ImwifSx7ImNoYXIiOiJlIn0seyJjaGFyIjoiciJ9LHsiY2hhciI6InQifSx7ImNoYXIiOiLmoYYifSx7ImNoYXIiOiLlhoUifSx7ImNoYXIiOiLmlocifSx7ImNoYXIiOiLmnKwifSx7ImNoYXIiOiLkv6EifSx7ImNoYXIiOiLmga8ifSx7ImNoYXIiOiItIn0seyJjaGFyIjoiLSJ9LHsiY2hhciI6Ij4ifSx7ImNoYXIiOiLngrkifSx7ImNoYXIiOiLlh7sifSx7ImNoYXIiOiLnoa4ifSx7ImNoYXIiOiLlrpoifSx7ImNoYXIiOiIvIn0seyJjaGFyIjoi5Y+WIn0seyJjaGFyIjoi5raIIn1dLCJpc1JpY2hUZXh0Ijp0cnVlLCJrZWVwTGluZUJyZWFrIjp0cnVlfX1d-->以上是关于使用pywinauto处理UI自动化,定位到了确定取消按钮,使用.click()运行没有反应的主要内容,如果未能解决你的问题,请参考以下文章
如何离线安装python模块?比如Windows下UI自动测试模块pywinauto
Pywinauto桌面应用自动化01--安装和启动
ui自动化元素定位怎么定位一个页面中不确定位置的按钮?
(selenium+python)_UI自动化09_定位alert弹窗
用pywinauto实现QT自动化
Pywinauto基础03--控件操作