Skip to content

Commit 9bcaa0c

Browse files
committed
Update code that processes URLs and HTML files
1 parent 6a51561 commit 9bcaa0c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,10 +1475,17 @@ def load_html_file(self, html_file, new_page=True):
14751475
def open_html_file(self, html_file):
14761476
""" Opens a local html file into the browser from a relative file path.
14771477
The URL displayed in the web browser will start with "file://". """
1478+
if self.__looks_like_a_page_url(html_file):
1479+
self.open(html_file)
1480+
return
14781481
if len(html_file) < 6 or not html_file.endswith(".html"):
14791482
raise Exception('Expecting a ".html" file!')
14801483
abs_path = os.path.abspath('.')
1481-
file_path = abs_path + "/%s" % html_file
1484+
file_path = None
1485+
if abs_path in html_file:
1486+
file_path = html_file
1487+
else:
1488+
file_path = abs_path + "/%s" % html_file
14821489
self.open("file://" + file_path)
14831490

14841491
def execute_script(self, script):
@@ -4642,7 +4649,8 @@ def __looks_like_a_page_url(self, url):
46424649
self.get_element(URL_AS_A_SELECTOR) if the input in not a URL. """
46434650
if (url.startswith("http:") or url.startswith("https:") or (
46444651
url.startswith("://") or url.startswith("data:") or (
4645-
url.startswith("about:") or url.startswith("chrome:")))):
4652+
url.startswith("about:") or url.startswith("chrome:") or (
4653+
url.startswith("file:"))))):
46464654
return True
46474655
else:
46484656
return False

0 commit comments

Comments
 (0)