Pass variables to click on a text in a Java app!

Hey everyone

I have an issue that I am trying to figure out.

So I have two variables:

  • ExamDate
  • ExamTime

I have a Java app that lists the exams in a window

A ExamDate ExamTime NY, XRAY - TEST
R ExamDate ExamTime LA, ULSOUND - TEST
C ExamDate ExamTime MI, XRAY - TEST

So what I need is to click on the appropriate exam depending on what is in the variable

Here is the selector

<wnd app='java*.exe' cls='SunAwtFrame' title='The app that I am using' />
<java name='APPOINTMENT: Patient' role='internal frame' />
<java cls='JList' role='list' />
<java name='A 24/09/2020 16:10 NY, XRAY - TEST' role='label' />

So how do I achieve this?

Should I go to Properties > Target > Selector and change to look something like this?

<java name=' "+ExamDate+ExamTime+" ' role='label' />

P.S What I should put in as a “Text must be quoted” in the activity? ExamDate + ExamTime ?

Hi @Mihajlo_Stojanovski

See here:
How to use variables in selectors in Studio (dynamic selectors) without string manipulation!

Thanks loginerror!

I will give it a try!

:smiley:

I tried with existing variables.

<java name='"A"+{{ExamDate}}+{{ExamTime}}' role='label' />

The reason why “A” is because currently there is no variable for that.

I changed this in Properties > Target, but I am getting this error.

Click 'label A': Cannot find the UI element corresponding to this selector: <wnd app='java*.exe' cls='SunAwtFrame' title='The title of the program' /><java name='APPOINTMENT: Patient' role='internal frame' /><java cls='JList' role='list' /><java name='&quot;A&quot;+21/09/2020+10:20' role='label' />

Can I add multiple dynamic selectors with + to find the appropriate exam?
Should it be in the format
‘{{ExamDate}}+{{ExamTime}}’
or
“+{{ExamDate}}+{{ExamTime}}+”
?

It’s actually simpler, you can join them like so:
image

You can use dynamic selector.

CaptureDynamicSelector

  1. I should use Click Text right?
    If so, then what to put in “Quoted text”

  2. I went into Properties > Target and entered this

"+ExamDate+"’ +’"+ExamTime+"

But for some reason I am getting back the old Indicate element values from the screen

<java name='A 24/09/2020 16:10 NY, XRAY - TEST' role='label' />

No simple click activity with this selector would work. Uncheck the simulate click and send window message property.

I tried the Click Activity, and I set the Uncheck the simulate click and Send Window message to False or not clicked, but for some reason it does not accept the value.

For an example:

<wnd app='java*.exe' cls='SunAwtFrame' title='The app that I am using' />
<java name='APPOINTMENT: Patient' role='internal frame' />
<java cls='JList' role='list' />

and if I add this:

<java name = '*"+ExamDate +"' +'"+ExamTime+"*' role ='label' />

It deletes it.

<wnd app='java*.exe' cls='SunAwtFrame' title='The app that I am using' />
<java name='APPOINTMENT: Patient' role='internal frame' />
<java cls='JList' role='list' />
<java name='A 24/09/2020 16:10 NY, XRAY - TEST' role='label' />

If I edit the selector to

<java name = '*"+ExamDate +"' +'"+ExamTime+"*' role ='label' />

I reverts back to

<java name='A 24/09/2020 16:10 NY, XRAY - TEST' role='label' />

Ok I managed to resolve the issue above.

But I got stuck with this

"<wnd app='java*.exe' cls='SunAwtFrame' title='TEST*' /><java name='APPOINTMENTS: Patient Search' role='internal frame' /><java cls='JList' role='list' /><java name == '*"+ExamDate +"' +'"+ExamTime+"*' role ='label' />"

Click ‘list’: The selector is not valid

OK I managed to make it work.
I used the Dynamic Selectors approach

<java name='{{LEtter}} {{ExamDate}} {{ExamTime}} {{Site}}, {{Resource}} - {{Description}}' role='label' />

It doesn’t Validate in the screen, but it does select the appropriate exam.

I reckon the alternative would be

’ “+LEtter+”’ +’"+ExamDate+"’ +’"+ExamTime+"’ +’ “+Site+” ’ ,’ “+Resource+” ’ - ’ “+Description+” ’

I think it is wrong. These placeholders I don’t quite understand them tbh :smiley:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.