microsoft / WinAppDriver

Windows Application Driver
MIT License
3.69k stars 1.4k forks source link

Can not find element by xpath on windows(1809) #1020

Open Emilymcwu opened 4 years ago

Emilymcwu commented 4 years ago

The same code,winappdriver can find element by xpath on windows(1903),can not find element by xpath on windows(1809)

My xpath code: String liveIdXpath = "/Pane[@ClassName=\"#32769\"][@Name=\"桌面 1\"]/Window[@Name=\"教师端\"][@AutomationId=\"LiveListDialog\"]/Group/Custom/Group/Group[position()=2]/Group[position()=2]/Group/Group/Group/Group[position()=1]/Text";

Output:

POST /session/5D362F92-3F7C-4CA1-A426-7F30804CD125/element HTTP/1.1 Accept-Encoding: gzip,deflate Connection: Keep-Alive Content-Length: 260 Content-Type: application/json; charset=utf-8 Host: 127.0.0.1:4723 User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_131)

{"using":"xpath","value":"/Pane[@ClassName=\"#32769\"][@Name=\"桌面 1\"]/Window[@Name=\"主讲教师端\"][@AutomationId=\"LiveListDialog\"]/Group/Custom[position()=2]/Group/Group[position()=2]/Group[position()=2]/Group/Group/Group/Group[position()=1]/Text"} HTTP/1.1 404 Not Found Content-Length: 139 Content-Type: application/json

{"status":7,"value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters."}}

uday2503 commented 4 years ago

@Emilymcwu is the issue resolved for you. If yes could you please tell me how?

khanhnd25 commented 4 years ago

Yes. I was able to make it work..I did this I did some trial and error and I removed the 1st token of the above XPATH.

Changed /Pane[@Name='Desktop 1']/Window[@Name='FusionReg-MockUI']/Window[@Name='FusionReg-MockUI']/RadioButton[@Name='QA']

to

/Window[@Name='FusionReg-MockUI']/Window[@Name='FusionReg-MockUI']/RadioButton[@Name='QA'] and it worked.