Page 1 of 1

Identifying Xpath via UserCode

Posted: Wed Jul 10, 2019 10:35 am
by Rich63
I'm currently running automative tests against a web application. However, I'm struggling at selecting dynamic dates set via usercode. Below is a modifed snippet of my workings:

String searchDate = DateTime.now.AddDays(1).ToString();

//..
formating searchDate correctly
...//

string selector = "/dom[@caption~'^site title']//div[#'paginator']/ul/li/a[@innerText~'^searchDate']";
Element elementX = Ranorex.Core.Element.FromPath(selector);

When inspecting elementX its Null. The selector above being used is from Ranorex Spy also.

Any help is appreciated

Re: Identifying Xpath via UserCode

Posted: Fri Jul 12, 2019 8:21 am
by odklizec
Hi,

To apply variable in code, you must use it like this:

Code: Select all

string selector = "/dom[@caption~'^site title']//div[#'paginator']/ul/li/a[@innerText~'^"+ searchDate+"']";
BTW, please post a Ranorex snapshot (NOT screenshot) of UI you are trying to automate. This would help us to understand your UI and eventually suggest best approach.