Skip to content

Commit bf4ff3b

Browse files
authored
Merge pull request #8 from hhslepicka/documentation
DOC: Add docstrings for tabs and other missing methods.
2 parents 7d42ee8 + cdaae02 commit bf4ff3b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

botcity/web/bot.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,12 +759,22 @@ def get_js_dialog(self):
759759
return None
760760

761761
def get_tabs(self):
762+
"""Get a list of tab handlers
763+
764+
Returns:
765+
list: List of tab handlers
766+
"""
762767
try:
763768
return self._driver.window_handles
764769
except InvalidSessionIdException:
765770
return []
766771

767772
def create_tab(self, url):
773+
"""Create a new tab and navigate to the given URL.
774+
775+
Args:
776+
url (str): The desired URL.
777+
"""
768778
try:
769779
# Refactor this when Selenium 4 is released
770780
self.execute_javascript(f"window.open('{url}', '_blank');")
@@ -773,6 +783,11 @@ def create_tab(self, url):
773783
self.navigate_to(url)
774784

775785
def create_window(self, url):
786+
"""Creates a new window with the given URL.
787+
788+
Args:
789+
url (str): The desired URL.
790+
"""
776791
try:
777792
# Refactor this when Selenium 4 is released
778793
self.execute_javascript(f"window.open('{url}', '_blank', 'location=0');")
@@ -781,6 +796,8 @@ def create_window(self, url):
781796
self.navigate_to(url)
782797

783798
def close_page(self):
799+
"""Close the current active page (tab or window).
800+
"""
784801
try:
785802
self._driver.close()
786803

@@ -792,6 +809,11 @@ def close_page(self):
792809
pass
793810

794811
def activate_tab(self, handle):
812+
"""Activate a tab given by the handle.
813+
814+
Args:
815+
handle (str): The tab or window handle.
816+
"""
795817
self._driver.switch_to.window(handle)
796818

797819
def print_pdf(self, path=None, print_options=None):

0 commit comments

Comments
 (0)