Check if element exists on page #2295
Replies: 3 comments 1 reply
-
Update to question 1 in my original post: However, it waits 7 seconds before concluding that the element does not exist, can I change this time? ( ideally to very low value) |
Beta Was this translation helpful? Give feedback.
-
Update again: Solution: If anyone can help with question 2 that would still be appreciated :) |
Beta Was this translation helpful? Give feedback.
-
For your first question: (Use those with an driver.is_element_present(selector)
driver.is_element_visible(selector) For your second question: (The default for driver.wait_for_element(selector, by="css selector", timeout=None) Here's all the new # "driver"-specific methods added by SeleniumBase
driver.default_get(url) # Because driver.get(url) works differently in UC Mode
driver.open(url) # Like driver.get(), but allows partial URLs without protocol
driver.click(selector)
driver.click_link(link_text)
driver.click_if_visible(selector)
driver.click_active_element()
driver.send_keys(selector, text)
driver.press_keys(selector, text)
driver.type(selector, text)
driver.submit(selector)
driver.assert_element(selector)
driver.assert_element_present(selector)
driver.assert_element_not_visible(selector)
driver.assert_text(text, selector)
driver.assert_exact_text(text, selector)
driver.wait_for_element(selector)
driver.wait_for_text(text, selector)
driver.wait_for_exact_text(text, selector)
driver.wait_for_and_accept_alert()
driver.wait_for_and_dismiss_alert()
driver.is_element_present(selector)
driver.is_element_visible(selector)
driver.is_text_visible(text, selector)
driver.is_exact_text_visible(text, selector)
driver.is_attribute_present(selector, attribute)
driver.get_text(selector)
driver.js_click(selector)
driver.get_active_element_css()
driver.get_locale_code()
driver.get_origin()
driver.get_user_agent()
driver.highlight(selector)
driver.highlight_click(selector)
driver.sleep(seconds)
driver.locator(selector)
driver.get_attribute(selector, attribute)
driver.get_page_source()
driver.get_title()
driver.switch_to_frame(frame)
############
# "driver"-specific methods added by SeleniumBase for UC Mode: "--uc" / uc=True
driver.uc_open(url)
driver.uc_open_with_tab(url)
driver.uc_open_with_reconnect(url, reconnect_time=None)
driver.reconnect(timeout)
driver.uc_click(
selector, by="css selector",
timeout=settings.SMALL_TIMEOUT, reconnect_time=None)
driver.uc_switch_to_frame(frame) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I have two quick questions.
Forward facing notes: I have setup SeleniumBase via;
from seleniumbase import Driver
driver = Driver(uc=True)
(aka im not using BaseCase)
Is it possible to check if an element on a page exists?
i.e IF element exists: Take action, Else: Take different action
Rather than using driver.sleep() to wait for an element to appear, is there a method that will auto wait until the element becomes available?
Beta Was this translation helpful? Give feedback.
All reactions