Noob here, couple of questions #2335
-
Hi, I'm trying to figure this out: 1:I'm trying to slow scroll to a specific element, and because there are multiple different elements with the same criteria and how my code works, I decided to use a
But then, I get this error: 2:If no matching element is found when using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hello. The Here's an example of from seleniumbase import SB
with SB() as sb:
sb.open("https://xkcd.com/color/rgb/")
sb.slow_scroll_to("center > table tbody tr:nth-child(36)")
sb.sleep(1) Use methods such as if sb.is_element_visible(selector):
# Do something here
else:
# Do something else here You can also use try:
# Do something here
except Exception:
# Do something else here |
Beta Was this translation helpful? Give feedback.
Hello. The
WebElement
doesn't contain theseleniumbase
methods (with a few exceptions for UC Mode).Here's an example of
slow_scroll_to()
:Use methods such as
is_element_visible(selector)
andis_element_present(selector)
to handle flow-of-control. Eg:You can also use
try/except
blocks for error-handling. Eg: