question

CRaman avatar image
CRaman Suspended asked CRaman Suspended posted

How do I progammatically decide which button to click in Java?

I have a need to click on a button based on the test assigned to the button.  I tried to do this with following description:

 

://button[@text='$i']:left

 

and then checking the box "For the Target field, perform command, variable, and backslash substitutions".  As soon as I check the box, I get a red 'X' with "Invalid substitution in field.  Command name cannot have substitutions."

 

Is there another way to do this?

iTestGUI Testing(Web-Java Swing-etc)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
PaulD avatar image
PaulD answered PaulD posted

You are doing the right thing.  But when you turn on substitution, those square brackets indicate that there should be a command inside them.  In this case, the square brackets are literal, so change it to

 

//button\[@text='$i'\]:left

 

and it should work.

1 comment
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

CRaman avatar image CRaman commented ·
Beautiful!  That worked!!
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.