Using sendKeys with no object select

Hello!
I am trying to use the sendkey feature without a selected target.
This is what I have right now, I select something in my table in row 3, shift over one arrow key, then press tab, then press enter. When i do it manually it works just fine, but when i run my code (below) it selects the button in row 4 instead of row 3.

See code below: any idea of what is happening here?
Thank you!

WebUI.click(findTestObject(‘Object Repository/Page_Dashboard/div_Dashboard’))

WebUI.click(findTestObject(‘Object Repository/Page_Dashboard/span_Local Hazards’))

WebUI.sendKeys(null, Keys.chord(Keys.ARROW_LEFT, Keys.TAB, Keys.ENTER))

Ading more more info here,
It seems as though the left arrow is is what is not taking, when i am pressing tab it it does to the next line which is why the whole selection is made. Not sure why the left arrow key function is not working.

Just a note that your code above is from Katalon Studio, not Katalon Recorder. Perhaps you are using the Web Recorder of Katalon Studio. Katalon Recorder is a separate product.

Instead of null, put in the element that was the last position you want to move away from. That is basically what you are doing manually, so do it with your code.

1 Like

Hi @grylion54,
Thank you!
I have update my code to be this:

WebUI.sendKeys(findTestObject(‘Object Repository/Page_Dashboard/span_Local Hazards (1)’), Keys.chord(Keys.ARROW_LEFT))

WebUI.delay(1)

WebUI.sendKeys(null, Keys.chord(Keys.TAB))

but am getting an erorr that says “com.kms.katalon.core.exception.StepFailedException: Unable to send keys ‘’ to object ‘Object Repository/Page_Dashboard/span_Local Hazards (1)’”

Okay, so it may have to be an input tag, or even maybe a select tag, that can “accept” the send keys.

Are you trying to move to a specific location, or just to enter the key combination?

Also, if you put code into this forum, put three backticks (i.e. ```) on a line by themselves above the code and three backticks on a line by themselves below the code. The backtick is found on the same key as the tilde (i.e. ~).