Skip to content

Commit

Permalink
Merge pull request #12 from hhslepicka/handle_iframe
Browse files Browse the repository at this point in the history
ENH: Add enter_iframe and leave_iframe to handle iFrames with WebBot.
  • Loading branch information
hhslepicka committed Nov 13, 2021
2 parents 861203e + 2a42273 commit e933e77
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions botcity/web/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,19 @@ def set_file_input_element(self, element: WebElement, filepath: str):
fpath = os.path.abspath(os.path.expanduser(os.path.expandvars(filepath)))
element.send_keys(fpath)

def enter_iframe(self, iframe: WebElement):
"""Switch the WebBot driver to the specified iframe.
Args:
iframe (WebElement): The desired iFrame.
"""
self._driver.switch_to.frame(iframe)

def leave_iframe(self):
"""Leave the iframe and switch the WebBot driver to the default content.
"""
self._driver.switch_to.default_content()

#######
# Mouse
#######
Expand Down

0 comments on commit e933e77

Please sign in to comment.