Skip to content

Commit e933e77

Browse files
authored
Merge pull request #12 from hhslepicka/handle_iframe
ENH: Add enter_iframe and leave_iframe to handle iFrames with WebBot.
2 parents 861203e + 2a42273 commit e933e77

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

botcity/web/bot.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,19 @@ def set_file_input_element(self, element: WebElement, filepath: str):
939939
fpath = os.path.abspath(os.path.expanduser(os.path.expandvars(filepath)))
940940
element.send_keys(fpath)
941941

942+
def enter_iframe(self, iframe: WebElement):
943+
"""Switch the WebBot driver to the specified iframe.
944+
945+
Args:
946+
iframe (WebElement): The desired iFrame.
947+
"""
948+
self._driver.switch_to.frame(iframe)
949+
950+
def leave_iframe(self):
951+
"""Leave the iframe and switch the WebBot driver to the default content.
952+
"""
953+
self._driver.switch_to.default_content()
954+
942955
#######
943956
# Mouse
944957
#######

0 commit comments

Comments
 (0)