seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
4.45k stars 908 forks source link

Pressing arrow keys #2875

Closed namename-123 closed 6 days ago

namename-123 commented 6 days ago

How can I press the arrow keys? In selenium you could do it by importing the Keys class, how can I do it in seleniumbase? Sorry for asking here since it's not really an appropriate place for questions but there's just nowhere else, you guys should make a Discord server for discussion and answers, I like this project and that'll help a low of newcomers into learning this wonderful library 😊

mdmintz commented 6 days ago

Here are the arrow key methods for the SB() manager / BaseCase formats:

self.press_up_arrow(selector="html", times=1, by="css selector")
self.press_down_arrow(selector="html", times=1, by="css selector")
self.press_left_arrow(selector="html", times=1, by="css selector")
self.press_right_arrow(selector="html", times=1, by="css selector")

You can also use the Keys class, like in regular Selenium:

from selenium.webdriver.common.keys import Keys
Keys.ARROW_UP
Keys.ARROW_DOWN
Keys.ARROW_LEFT
Keys.ARROW_RIGHT