XPath locator for Edit box is not working
smtripathi99 opened this issue · comments
Hi,
I have a window application and I am trying to locate Password filed using xpath but it is not working. I tried followings:
driver.findElement(By.xpath("/[contains(@ControlType,'ControlType.Window') and contains(@name,'Sabre Travel Network')]//[contains(@ControlType,'ControlType.Edit') and contains(@name,'Password')]"));
driver.findElement(By.xpath("//[contains(@classname,'SWT_Window0') and contains(@name,'Travel Network')]//[contains(@ControlType,'ControlType.Edit') and (@name='Password')]"));
driver.findElement(By.xpath("//[contains(@processid,'sabrered') and contains(@name,'Travel Network')]//[contains(@ControlType,'ControlType.Edit') and (@name='Password')]"))
@smtripathi99 maybe try with WADUIRecorder. You might be able to you automationid and use it as the id in winnium
Please provide the URL to download WAD UIRecorder
I have got the source for UI Recorder https://github.com/microsoft/WinAppDriver/tree/master/Tools/UIRecorder/UIRecorder.
How can I run it?
You can get it from https://github.com/microsoft/WinAppDriver/releases/tag/UiR_v1.0-RC
Scroll down and download the .zip file. Inside the unzipped folder you will find : WinAppDriverUiRecorder.exe
Just run that and open your application and move your mouse to the control . You might be able to get the automation id or name for the element. You can use this in your winium code
Thanks i can run it now and see the xpath but code mention under C# is not working. Unable to find element comes
Did you try using id or name instead of xpath. From the UI recorder you can use the "automation id" as the id in your code and "Name" as the name below
IWebElement element = driver.FindElement(By.Name("xxxxxx"));
or
IWebElement element = driver.FindElement(By.id("xxxxxx"));
Automation id seems to be dynamic and name also does not work. Following is what i got
"/Pane[@name="Desktop 1"][@classname="#32769"]/Window[@name="Travel Network"][@classname="SWT_Window0"]/Pane[@classname="SWT_Window0"]/Pane[@classname="SWT_Window0"]/Pane[@classname="SWT_Window0"]/Pane[@classname="SWT_Window0"]/Edit[@name="Password"][@classname="Edit"]"