Search element in App Folder

Best practices, code snippets for common functionality, examples, and guidelines.
PawanAher
Posts: 2
Joined: Thu Nov 12, 2020 11:28 am

Search element in App Folder

Post by PawanAher » Thu Nov 12, 2020 11:48 am

Hello,

I am trying to automate desktop application which is having web based login. URL of the login window changes daily.
I have app folder in repo-> LoginWindow- /dom[@domain='euw1-23qna11002-iam.3dx-staging.3ds.com']
and element1 -> User Name - //div[#'inner']/?/?/form[@action='https://euw1-23qna11002-iam.3dx-staging ... Metadata_0']/fieldset/div[3]/?/?/input[@name='username']
element2 -> Password - //div[#'inner']/?/?/form[@action='https://euw1-23qna11002-iam.3dx-staging ... Metadata_0']/fieldset/div[4]/?/?/input[@name='password']
element3 -.Submit -

Question - As Urls' of element1 and element2 changes daily I want to search the element in the app folder(LoginWindow)
like txtUserName = LoginWindow.FindElement(input[@name='username']) or txtPassword = LoginWindow.FindElement(input[@name='password'])
and set the values txtUserName.SendKeys("abc")
I created 2 tickets at Ranorex support but no reply from them.
Can some someone help me?

Thanks,
Pawan
Attachments
LoginWindow.rxsnp
(82.33 KiB) Downloaded 2 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6360
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Search element in App Folder

Post by odklizec » Fri Nov 13, 2020 8:12 am

Hi,

Why don't you use class attribute, instead of action attribute? It seems to be filled with reasonable and what appears to be static information? So you can use xpaths like these..
//div[#'inner']/?/?/form[@class~'uwa-input-form login-form']//input[@name='username']
//div[#'inner']/?/?/form[@class~'uwa-input-form login-form']//input[@name='password']
Ideally, create a root folder under DOM element, containing just this part of xpath...
//div[#'inner']/?/?/form[@class~'uwa-input-form login-form']
And inside create two input repo elements for username and password. Then simply pass repo elements to code via method parameters.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

PawanAher
Posts: 2
Joined: Thu Nov 12, 2020 11:28 am

Re: Search element in App Folder

Post by PawanAher » Fri Nov 13, 2020 11:01 am

odklizec wrote:
Fri Nov 13, 2020 8:12 am
Hi,

Why don't you use class attribute, instead of action attribute? It seems to be filled with reasonable and what appears to be static information? So you can use xpaths like these..
//div[#'inner']/?/?/form[@class~'uwa-input-form login-form']//input[@name='username']
//div[#'inner']/?/?/form[@class~'uwa-input-form login-form']//input[@name='password']
Ideally, create a root folder under DOM element, containing just this part of xpath...
//div[#'inner']/?/?/form[@class~'uwa-input-form login-form']
And inside create two input repo elements for username and password. Then simply pass repo elements to code via method parameters.
It's working, Thanks a lot :)