How to click on text when it is provided by a variable?

Hi Everyone , Anyone knows how to click on text when it is provided by a variable? like xclick | ${var}, Anyone tried this?

Error I got is [error]
Line 44: E316: XClick: invalid target, ‘2UD’

Xclick require Xpath or image name to click not a variable

Read here how it works

Or you can try the new XClickText | ${var}

It uses text recognition (OCR) to find the text.

1 Like

Hi @Plankton , I am facing below issue when I try above command.
Line 47: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type undefined

Undefined means your “var” doesn’t exist prior to the XClickText command. Are you filling the variable with text properly?

Yes @Elpin , It is even stored in variables section

OK, I actually read the documentation and it says the command is actually XClickText | ocr=${var}

Means there should be ocr= in front of the variable name.

Can you try it like that instead?

There are an other option to click with a variable

Use a generic xpath like (it is an example)

CLICK | xpath=(//a[contains(.,‘${var}’)])[1]

This click a link with ${var} content and have not limitation of Xclick (limited command without license, focus on screen, not minimized windows to works)

1 Like

Xclicktext only works on text.( things that shows text cursor when you mouse hover. ).
if its not a text then use Xclick using Xpath.