File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,25 @@ def get_session(driver: webdriver) -> str:
2222 return driver .session_id
2323
2424
25+ def is_local (path : str ) -> str :
26+ """Return valid URL path for file
27+
28+ Args:
29+ path (str): normal path or URL
30+
31+ Returns:
32+ str: Modified file path if local file
33+ Returns path as it is if URL
34+ """
35+ import os
36+
37+ URL = path
38+ if os .path .exists (path ) or path .startswith ("file" ):
39+ if not URL .startswith ("file" ):
40+ URL = f"file://{ URL } "
41+ return URL
42+
43+
2544def visit (driver : webdriver , url : str ) -> None :
2645 """Visit given url
2746
@@ -32,7 +51,7 @@ def visit(driver: webdriver, url: str) -> None:
3251 Returns:
3352 None
3453 """
35- driver .get (url )
54+ driver .get (is_local ( url ) )
3655
3756
3857def page_source (driver : webdriver ) -> str :
You can’t perform that action at this time.
0 commit comments