Reputation: 33
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"
Upvotes: 2
Views: 2886
Reputation: 20839
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.
Upvotes: 1