Appium 求助 appium 测试 windows desktop 应用时窗口切换问题

rywu · 2018年05月28日 · 最后由 rywu 回复于 2018年06月08日 · 1638 次阅读

背景:

应用登录后,发现窗口变掉了。导致元素 找不到

个人想法:

appium 在测试 windows desktop 应用的时候,如何进行窗口切换?

想法是 首先获取 所有的窗口 handles,但是执行完

GET  /session/:sessionId/window_handles

发现只有一个返回

实际结果:

Starting test: UIBaiduTest.BaiduTestSuite.BaiduTest
20180528 10:40:11.936 :  INFO : Slept 3 seconds
20180528 10:40:11.937 :  INFO : Clicking element 'name=PasswordTextEdit'.
20180528 10:40:13.826 :  INFO : Typing text 'admin123' into text field 'name=PasswordTextEdit'
20180528 10:40:15.825 :  INFO : Clicking element 'accessibility_id=btnLogin'.
20180528 10:40:37.507 :  INFO : Slept 20 seconds
20180528 10:40:37.707 :  INFO : ${pagesource} = <?xml version="1.0" encoding="utf-16"?><Pane AcceleratorKey="" AccessKey="" AutomationId="" ClassName="" FrameworkId="Win32" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlEleme...
20180528 10:40:37.709 :  INFO : <?xml version="1.0" encoding="utf-16"?><Pane AcceleratorKey="" AccessKey="" AutomationId="" ClassName="" FrameworkId="Win32" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="True" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="窗格" Name="登录" Orientation="None" ProcessId="0" RuntimeId="42.1973448" x="0" y="0" width="0" height="0" />
20180528 10:40:37.919 :  INFO : ${pagecontexts} = 0x001E1CC8
20180528 10:40:37.920 :  INFO : 0x001E1CC8
20180528 10:40:37.923 :  INFO : Clicking element 'name=客户管理'.
20180528 10:40:38.102 :  FAIL : 
WebDriverException: Message: An unknown error occurred in the remote end while processing the command.

20180528 10:40:38.104 :  WARN : 
Keyword 'Capture Page Screenshot' could not be run on failure: WebDriverException: Message: An unknown error occurred in the remote end while processing the command.

20180528 10:40:38.108 :  FAIL : ValueError: Element locator 'name=客户管理' did not match any elements.

求助

怎么实现窗口的切换,或者找到该元素呢

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 3 条回复 时间 点赞
rywu #1 · 2018年05月28日 Author

解决方案 1

使用 appTopLevelWindow
Existing application top level window to attach to
有个缺点,每次需要手动获取 window handle,因为每次不一样

请问您的联系方式是多少?这个解决方案没看懂

rywu #3 · 2018年06月08日 Author

#2 楼 @xiaohengdada 简单说就是预先打开应用,然后使用 appium 绑定这个应用。

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

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册