aboutsummaryrefslogtreecommitdiff
path: root/src/ee/_utils.py
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-10-26 22:13:41 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-10-26 22:13:49 +0200
commit1c3b5f628b310c64f0da36247f5044d69b97d772 (patch)
treeb1d8b62d8f2e4d8c203281bef42e3c0c4e404971 /src/ee/_utils.py
parentd49e748f4605f26d5b65caea05773ea8a2dd0eb0 (diff)
downloadee-python-1c3b5f628b310c64f0da36247f5044d69b97d772.tar.gz
ee-python-1c3b5f628b310c64f0da36247f5044d69b97d772.tar.bz2
ee-python-1c3b5f628b310c64f0da36247f5044d69b97d772.tar.xz
ee-python-1c3b5f628b310c64f0da36247f5044d69b97d772.zip
digikey: Better webdriver creation.
Making the instantiation of the web driver a bit more generic, starting on making it possible to try out other browsers.
Diffstat (limited to 'src/ee/_utils.py')
-rw-r--r--src/ee/_utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ee/_utils.py b/src/ee/_utils.py
index 5960161..0aa12ae 100644
--- a/src/ee/_utils.py
+++ b/src/ee/_utils.py
@@ -79,6 +79,25 @@ def maybe_cache(path: Optional[Path], **kwargs) -> HttpCache:
return HttpCache(path, **kwargs) if path is not None else EmptyHttpCache()
+def get_web_driver(): # selenium.webdriver.remote.webdriver.WebDriver
+ import selenium.common.exceptions
+ from selenium import webdriver
+
+ drivers = [
+ ("chrome", webdriver.Chrome),
+ # ("firefox", webdriver.Firefox),
+ # ("webkit", webdriver.WebKitGTK),
+ ]
+
+ for key, constructor in drivers:
+ try:
+ return constructor()
+ except selenium.common.exceptions.WebDriverException:
+ pass
+
+ return webdriver.Chrome()
+
+
def gen_rst_table(header: List[str], data: List[List[str]]):
column_widths = []
for i in range(len(header)):