Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karate Robot cannot handle the ‘>’ character, yield org.graalvm.polyglot.PolyglotException: Invalid key code #2523

Open
cloudmadeofcandy opened this issue Mar 4, 2024 · 4 comments
Assignees
Milestone

Comments

@cloudmadeofcandy
Copy link

I have a reproducible code:

`
Feature: Test

Scenario: Test
Given robot { window: '^Notepad', fork: 'notepad', highlight: true, highlightDuration: 500 }
* click('Text Editor')
* input('>>')
`

everything ran as is, except for the final line * input('>>'), which first gave a warning:

[main] WARN com.intuit.karate - cannot resolve char: >

Then an error:
org.graalvm.polyglot.PolyglotException: Invalid key code

  • java.desktop/sun.awt.windows.WRobotPeer.keyPress(Native Method)
  • java.desktop/java.awt.Robot.keyPress(Robot.java:351)
  • com.intuit.karate.robot.RobotBase.input(RobotBase.java:368)
  • .:anonymous(Unnamed:1) -

Why can’t I input the symbol ‘>’?

@ptrthomas
Copy link
Member

it looks like we may have completely missed adding this here: https://github.com/karatelabs/karate/blob/master/karate-robot/src/main/java/com/intuit/karate/robot/RobotUtils.java

this is a great opportunity for you to submit a PR after confirming it works for you, do you want to try ?

@cloudmadeofcandy
Copy link
Author

cloudmadeofcandy commented Mar 5, 2024

While I would absolutely love to create a PR and contribute, but due to security policies that are employed by my company, I am not allowed to do so. (Nor is it in my ability to do so, since I don’t have a personal laptop - I am typing on an iPad).

Which is annoying, since I can see that I can just add in another line of code…

I’ll wait for a patch, though :D

@cloudmadeofcandy
Copy link
Author

I found the problem, it’s on line 248 of the file you sent: https://github.com/karatelabs/karate/blob/master/karate-robot/src/main/java/com/intuit/karate/robot/RobotUtils.java

Apparently the symbol ‘|’ is repeated twice, on line 240 (the right one) and line 248 (which should be ‘>’)

@ptrthomas
Copy link
Member

@cloudmadeofcandy thanks for the details ! when there is a new version, I'll update this ticket so you know. hopefully within a couple of weeks

ptrthomas added a commit that referenced this issue Mar 5, 2024
@ptrthomas ptrthomas self-assigned this Mar 5, 2024
@ptrthomas ptrthomas added this to the 1.5.0 milestone Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants