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

Method switch_to_frame

seleniumbase/fixtures/base_case.py:3692–3758  ·  view source on GitHub ↗

Wait for an iframe to appear, and switch to it. This should be usable as a drop-in replacement for driver.switch_to.frame(). The iframe identifier can be a selector, an index, an id, a name, or a web element, but scrolling to the iframe first will only occur for visib

(self, frame="iframe", timeout=None, invisible=False)

Source from the content-addressed store, hash-verified

3690 self.__demo_mode_pause_if_active(tiny=True)
3691
3692 def switch_to_frame(self, frame="iframe", timeout=None, invisible=False):
3693 """Wait for an iframe to appear, and switch to it. This should be
3694 usable as a drop-in replacement for driver.switch_to.frame().
3695 The iframe identifier can be a selector, an index, an id, a name,
3696 or a web element, but scrolling to the iframe first will only occur
3697 for visible iframes with a string selector.
3698 @Params
3699 frame - the frame element, name, id, index, or selector
3700 timeout - the time to wait for the alert in seconds
3701 invisible - if True, the iframe can be invisible """
3702 self.__check_scope()
3703 if not timeout:
3704 timeout = settings.LARGE_TIMEOUT
3705 if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
3706 timeout = self.__get_new_timeout(timeout)
3707 if self.__needs_minimum_wait():
3708 time.sleep(0.05)
3709 if self.undetectable:
3710 time.sleep(0.05)
3711 if isinstance(frame, str) and self.is_element_visible(frame):
3712 try:
3713 self.scroll_to(frame, timeout=1)
3714 if self.__needs_minimum_wait():
3715 time.sleep(0.04)
3716 if self.undetectable:
3717 time.sleep(0.04)
3718 except Exception:
3719 time.sleep(0.02)
3720 else:
3721 if self.__needs_minimum_wait():
3722 time.sleep(0.05)
3723 if self.undetectable:
3724 time.sleep(0.05)
3725 if self.undetectable:
3726 self.__uc_frame_layer += 1
3727 if (
3728 self.recorder_mode
3729 and self._rec_overrides_switch
3730 and self.__current_url_is_recordable()
3731 ):
3732 r_a = self.get_session_storage_item("recorder_activated")
3733 if r_a == "yes":
3734 time_stamp = self.execute_script("return Date.now();")
3735 origin = self.get_origin()
3736 action = ["sk_op", "", origin, time_stamp]
3737 self.__extra_actions.append(action)
3738 time_stamp = self.execute_script("return Date.now();")
3739 self.__set_c_from_switch = True
3740 self.set_content_to_frame(frame, timeout=timeout)
3741 self.__set_c_from_switch = False
3742 origin = self.get_origin()
3743 action = ["sw_fr", frame, origin, time_stamp]
3744 self.__extra_actions.append(action)
3745 return
3746 self.wait_for_ready_state_complete()
3747 if self.__needs_minimum_wait():
3748 time.sleep(0.035)
3749 if self.undetectable:

Callers 15

get_gui_element_rectMethod · 0.95
frame_switchMethod · 0.95
switch_to_frameFunction · 0.45
passer_au_cadreMethod · 0.45
passa_alla_corniceMethod · 0.45
cambiar_al_marcoMethod · 0.45

Calls 12

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
__needs_minimum_waitMethod · 0.95
is_element_visibleMethod · 0.95
scroll_toMethod · 0.95
execute_scriptMethod · 0.95
get_originMethod · 0.95
set_content_to_frameMethod · 0.95
sleepMethod · 0.45

Tested by 11

test_demo_siteMethod · 0.36
test_iframe_basicsMethod · 0.36
test_animationMethod · 0.36
test_demo_siteMethod · 0.36
test_tinymceMethod · 0.36
test_demo_pageMethod · 0.36