Use Webdriver Manager for browser compatibility

Version mismatch between browser and selenium driver breaks the tests.
The Webdriver manager automatically ensures the compatibility by
downloading the right driver for the installed browser.
This commit is contained in:
Carsten Grohmann 2021-07-21 22:40:41 +02:00
parent c9b665b464
commit 1abf455711
4 changed files with 13 additions and 1 deletions

3
.gitignore vendored
View File

@ -9,6 +9,9 @@ env/
# IntelliJ project files # IntelliJ project files
.idea .idea
# Webdriver Manager: cache for selenium drivers
.wdm
# Generated (compiled) JavaScript code # Generated (compiled) JavaScript code
__target__/ __target__/
OOMAnalyser.js OOMAnalyser.js

View File

@ -39,6 +39,7 @@ clean:
@find $(BASE_DIR) -depth -type f -name "*.pyo" -exec rm -f {} \; @find $(BASE_DIR) -depth -type f -name "*.pyo" -exec rm -f {} \;
@find $(BASE_DIR) -depth -type f -name "*.orig" -exec rm -f {} \; @find $(BASE_DIR) -depth -type f -name "*.orig" -exec rm -f {} \;
@find $(BASE_DIR) -depth -type f -name "*~" -exec rm -f {} \; @find $(BASE_DIR) -depth -type f -name "*~" -exec rm -f {} \;
@$(RM) --force --recursive .wdm
@$(RM) --force --recursive __target__ @$(RM) --force --recursive __target__
#+ Remove all automatically generated and Git repository data #+ Remove all automatically generated and Git repository data

View File

@ -1,2 +1,3 @@
Transcrypt == 3.7.16 Transcrypt == 3.7.16
selenium selenium
webdriver-manager

View File

@ -24,6 +24,7 @@ import threading
import unittest import unittest
from selenium import webdriver from selenium import webdriver
from selenium.common.exceptions import * from selenium.common.exceptions import *
from webdriver_manager.chrome import ChromeDriverManager
import warnings import warnings
import OOMAnalyser import OOMAnalyser
@ -84,7 +85,13 @@ class TestInBrowser(TestBase):
server_thread.daemon = True server_thread.daemon = True
server_thread.start() server_thread.start()
self.driver = webdriver.Chrome() # silent Webdriver Manager
os.environ['WDM_LOG_LEVEL'] = '0'
# store driver locally
os.environ['WDM_LOCAL'] = '1'
self.driver = webdriver.Chrome(ChromeDriverManager().install())
self.driver.get("http://127.0.0.1:8000/OOMAnalyser.html") self.driver.get("http://127.0.0.1:8000/OOMAnalyser.html")
def tearDown(self): def tearDown(self):