背景:

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

个人想法:

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.

求助

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


↙↙↙阅读原文可查看相关链接,并与作者交流