Skip to content

Commit 16e5ee6

Browse files
committed
Add "open_start_page()" method
1 parent 35d563e commit 16e5ee6

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

help_docs/method_summary.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ self.go_back()
5656

5757
self.go_forward()
5858

59+
self.open_start_page()
60+
5961
self.is_element_present(selector, by=By.CSS_SELECTOR)
6062

6163
self.is_element_visible(selector, by=By.CSS_SELECTOR)

seleniumbase/fixtures/base_case.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,28 @@ def go_forward(self):
652652
self.wait_for_ready_state_complete()
653653
self.__demo_mode_pause_if_active()
654654

655+
def open_start_page(self):
656+
""" Navigates the current browser window to the start_page.
657+
You can set the start_page on the command-line in three ways:
658+
'--start_page=URL', '--start-page=URL', or '--url=URL'.
659+
If the start_page is not set, then "data:," will be used. """
660+
self.__check_scope()
661+
start_page = self.start_page
662+
if type(start_page) is str:
663+
start_page = start_page.strip() # Remove extra whitespace
664+
if start_page and len(start_page) >= 4:
665+
if page_utils.is_valid_url(start_page):
666+
self.open(start_page)
667+
else:
668+
new_start_page = "http://" + start_page
669+
if page_utils.is_valid_url(new_start_page):
670+
self.open(new_start_page)
671+
else:
672+
logging.info('Invalid URL: "%s"!' % start_page)
673+
self.open("data:,")
674+
else:
675+
self.open("data:,")
676+
655677
def is_element_present(self, selector, by=By.CSS_SELECTOR):
656678
self.wait_for_ready_state_complete()
657679
selector, by = self.__recalculate_selector(selector, by)

0 commit comments

Comments
 (0)