Context Manager for switching into iframes. Usage example: with self.frame_switch("iframe"): # Perform actions here that should be done within the iframe. # The iframe is automatically exited after the "with" block ends.
(self, frame, timeout=None)
| 3811 | |
| 3812 | @contextmanager |
| 3813 | def frame_switch(self, frame, timeout=None): |
| 3814 | """ Context Manager for switching into iframes. |
| 3815 | Usage example: |
| 3816 | with self.frame_switch("iframe"): |
| 3817 | # Perform actions here that should be done within the iframe. |
| 3818 | # The iframe is automatically exited after the "with" block ends. |
| 3819 | """ |
| 3820 | if self.recorder_mode: |
| 3821 | self.__frame_switch_layer += 1 |
| 3822 | if self.__frame_switch_layer >= 2: |
| 3823 | self.__frame_switch_multi = True |
| 3824 | self.switch_to_frame(frame, timeout=timeout) |
| 3825 | if self.undetectable: |
| 3826 | self.__uc_frame_layer += 1 |
| 3827 | yield |
| 3828 | if self.undetectable: |
| 3829 | self.__uc_frame_layer -= 1 |
| 3830 | if self.__uc_frame_layer < 0: |
| 3831 | self.__uc_frame_layer = 0 |
| 3832 | self.switch_to_parent_frame() |
| 3833 | if self.recorder_mode: |
| 3834 | self.__frame_switch_layer -= 1 |
| 3835 | if self.__frame_switch_layer < 0: |
| 3836 | self.__frame_switch_layer = 0 |
| 3837 | self.__frame_switch_multi = False |
| 3838 | if self.__frame_switch_layer == 0 and self.__frame_switch_multi: |
| 3839 | self.refresh() |
| 3840 | self.__frame_switch_multi = False |
| 3841 | |
| 3842 | def set_content_to_frame(self, frame, timeout=None): |
| 3843 | """Replaces the page html with an iframe's html from that page. |