MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / save_screenshot

Method save_screenshot

seleniumbase/fixtures/base_case.py:4545–4577  ·  view source on GitHub ↗

Saves a screenshot of the current page. If no folder is specified, uses the folder where pytest was called. The screenshot will include the entire page unless a selector is given. If a provided selector is not found, then takes a full-page screenshot. If the folder pr

(
        self, name, folder=None, selector=None, by="css selector"
    )

Source from the content-addressed store, hash-verified

4543 self.bring_active_window_to_front()
4544
4545 def save_screenshot(
4546 self, name, folder=None, selector=None, by="css selector"
4547 ):
4548 """Saves a screenshot of the current page.
4549 If no folder is specified, uses the folder where pytest was called.
4550 The screenshot will include the entire page unless a selector is given.
4551 If a provided selector is not found, then takes a full-page screenshot.
4552 If the folder provided doesn't exist, it will get created.
4553 The screenshot will be in PNG format: (*.png)"""
4554 if self.__is_cdp_swap_needed():
4555 self.cdp.save_screenshot(name, folder=folder, selector=selector)
4556 return
4557 self.wait_for_ready_state_complete()
4558 if selector and by:
4559 selector, by = self.__recalculate_selector(selector, by)
4560 if page_actions.is_element_present(self.driver, selector, by):
4561 return page_actions.save_screenshot(
4562 self.driver, name, folder, selector, by
4563 )
4564 if self.recorder_mode:
4565 url = self.get_current_url()
4566 if url and len(url) > 0:
4567 if ("http:") in url or ("https:") in url or ("file:") in url:
4568 if self.get_session_storage_item("pause_recorder") == "no":
4569 time_stamp = self.execute_script("return Date.now();")
4570 origin = self.get_origin()
4571 if not folder:
4572 action = ["s_scr", name, origin, time_stamp]
4573 else:
4574 name_folder = [name, folder]
4575 action = ["ss_tf", name_folder, origin, time_stamp]
4576 self.__extra_actions.append(action)
4577 return page_actions.save_screenshot(self.driver, name, folder)
4578
4579 def save_screenshot_to_logs(
4580 self, name=None, selector=None, by="css selector"

Callers 2

check_windowMethod · 0.95

Calls 8

__is_cdp_swap_neededMethod · 0.95
get_current_urlMethod · 0.95
execute_scriptMethod · 0.95
get_originMethod · 0.95
is_element_presentMethod · 0.45

Tested by

no test coverage detected