1

I'm unable to find the right XPath expression for a Windows Element. I have an automation script that works on Windows 10 Enterprise but doesn't work on Windows Server OS My main question is why does Appium work on Windows 10 Enterprise OS but not on Windows Server OS?

Im using Appium to automate a Desktop workflow on Windows. So what I'm doing is I'm clicking on the search button on the taskbar, searching for Teams and clicking on the search result.

1

This statement works on Windows Server 2019, but not on Windows 10 Enterprise

pageDriver.findElementByName("Microsoft Teams, Desktop app").click()

The statement that works on Windows 10 Enterprise but not on Windows Server 2019

pageDriver.findElementByName("Microsoft Teams, App, Press right to switch preview").click()

That's understandable when I inspect the element the Names are different so I have to find a solution that works on both so I decided to use XPath. But all the following XPath expressions are throwing InvalidSelectorException on both Windows Server and Windows 10 Enterprise. Both have Developer mode enabled.

pageDriver.findElementByXPath("//ListItem[starts-with(@Name, 'Microsoft Teams']");
pageDriver.findElementByXPath("//ListItem[contains(@Name, 'Microsoft Teams']");
pageDriver.findElementByXPath("//List[@Name='Results'][@AutomationId='suggestionsList']/ListItem[starts-with(@Name, 'Microsoft Teams']");

The full recorded xpath using WinAppDriverUIRecorder for the element on Windows Server is

"/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Window[@ClassName=\"Windows.UI.Core.CoreWindow\"][@Name=\"Search\"]/Pane[@ClassName=\"WebView\"][@Name=\"Bing\"]/Pane[@Name=\"Bing\"]/List[@Name=\"Results\"][@AutomationId=\"suggestionsList\"]/ListItem[@Name=\"Microsoft Teams, Desktop app\"][starts-with(@AutomationId,\"id_\")]"

The full recorded xpath on Windows 10 Enterprise is

"/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Window[@ClassName=\"Windows.UI.Core.CoreWindow\"][@Name=\"Search\"]/Pane[@ClassName=\"WebView\"][@Name=\"Bing\"]/Pane[@Name=\"Bing\"]/List[@Name=\"Results\"][@AutomationId=\"suggestionsList\"]/ListItem[@Name=\"Microsoft Teams, App, Press right to switch preview\"][@AutomationId=\"PPMicrosoft Teams\"]"

What am I doing wrong?

But here's the follow-up, I'm able to automate the whole workflow with MS Teams on Windows 10 Enterprise OS, but not on Windows Server. Even if I ignore this one statement that brings up MS Teams and go with a different statement on the Windows Server OS, all the rest of the statements like

  • clicking on a Team
  • Adding a Tab to a team
  • Interacting with elements inside the tab

are all working in Windows 10 Enterprise OS but not on Windows Server. This is the weirdest thing. I have to make my scripts work on both Windows 10 Enterprise and Windows Server. Currently, on Windows 10 the scripts are working with AccessibilityIDs and Names, but that does not seem to work on Windows Server. And to make matters worse I have this xpath issue. What can I do here?

Thanks in advance.

Ravi Teja
  • 11
  • 2

0 Answers0