I'm trying to automate a Windows Printer Driver Application on windows 10 pro with newest WinAppDriver v1.2.1.WinAppDriver. The test script cannot locate any element on the Preferences Window, which is a Modal window's Modal Window. The test scenario is as below:
Here is my sample code, using Appium-Python-Client library:
from appium import webdriver
desired_caps = {}
desired_caps["app"] = "C:\\Windows\\notepad.exe"
desired_caps["platformName"] = "windows"
driver = webdriver.Remote(
command_executor='http://127.0.0.1:4723',
desired_capabilities= desired_caps)
driver.find_element_by_name("ファイル(F)").click()
driver.find_element_by_accessibility_id("6").click()
# click elements on the Print modal window
driver.find_element_by_accessibility_id("1010").click()
# click elements on the Preferences modal window
driver.find_element_by_xpath("/Pane[@ClassName=\"#32769\"][@Name=\"デスクトップ 1\"]/Window[@ClassName=\"#32770\"][@Name=\"印刷設定\"]/Tab[@ClassName=\"SysTabControl32\"]/TabItem[@Name=\" 拡張機能 \"]").click()
driver.find_element_by_xpath("/Pane[@ClassName=\"#32769\"][@Name=\"デスクトップ 1\"]/Window[@ClassName=\"#32770\"][@Name=\"印刷設定\"]/Button[@ClassName=\"Button\"][@Name=\"設定(E)...\"]").click()
driver.find_element_by_xpath("/Pane[@ClassName=\"#32769\"][@Name=\"デスクトップ 1\"]/Window[@ClassName=\"#32770\"][@Name=\"印刷設定\"]/Window[@ClassName=\"#32770\"][@Name=\"セキュリティ印刷設定\"]/CheckBox[@ClassName=\"Button\"][@Name=\"セキュリティ印刷(S)\"]").click()
The WinAppDriver's log:
{"status":7,"value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters."}}
Is there any other way to locate elements on the descendant Modal window, Preferences Modal window?
The second modal window (Preferences Modal window ) is actually treated as a new window(whose window handle is managed by winappdriver). After switching the session to that window, and using relative xpath, I solved the problem.