2

I want selenium to open page and wait for keypress, based on key pressed script should do different actions. It seems there is no Expected Conditions for this case, how can I write my own?

Here is pseudo code:

driver.get('http://google.com')
# wait for keypress
# if keypress == ARROW_RIGHT:
#     print "ARROW_RIGHT"
# elif keypress == ARROW_LEFT:
#     print "ARROW_LEFT"

1 Answer 1

1

You will need to use a python method to check for a key press input. There are different ways to do this depending on if you are using a GUI support library or not. Take a look at this answer, which covers multiple ways on how to work with key presses.

After you detected a key press you can continue performing your task in Selenium.

Sign up to request clarification or add additional context in comments.

1 Comment

This seems like the right answer to accept. I don't claim to have a full overview of seleniums API, but bear in mind that it is an automatic testing library, and that manual inputs are probably out of scope.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.