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)
| 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: |