Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XPath locator for Edit box is not working #341

Open
smtripathi99 opened this issue Feb 12, 2021 · 7 comments
Open

XPath locator for Edit box is not working #341

smtripathi99 opened this issue Feb 12, 2021 · 7 comments

Comments

@smtripathi99
Copy link

smtripathi99 commented Feb 12, 2021

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')]"))

@anileapen
Copy link

@smtripathi99 maybe try with WADUIRecorder. You might be able to you automationid and use it as the id in winnium

image

@smtripathi99
Copy link
Author

@anileapen ,

Please provide the URL to download WAD UIRecorder

@smtripathi99
Copy link
Author

I have got the source for UI Recorder https://github.com/microsoft/WinAppDriver/tree/master/Tools/UIRecorder/UIRecorder.
How can I run it?

@anileapen
Copy link

anileapen commented Feb 14, 2021

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

@smtripathi99
Copy link
Author

Thanks i can run it now and see the xpath but code mention under C# is not working. Unable to find element comes

@anileapen
Copy link

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"));

@smtripathi99
Copy link
Author

smtripathi99 commented Feb 14, 2021

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"]"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants