Skip to content

Commit

Permalink
Resolve #8 tentatively
Browse files Browse the repository at this point in the history
  • Loading branch information
nalvarez508 committed Mar 27, 2022
1 parent af9f915 commit 6ba22be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions railpass_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ def onClose(self):
self.destroy()
# Close webdrivers
self.imageArea.imageCatcher.driver.close()
self.searcher.driver.close()
self.imageArea.imageCatcher.driver.quit()
self.searcher.driver.close()
self.searcher.driver.quit()
sys.exit()

def __startup(self):
self.searcher = AmtrakSearch(self, Driver(cfg.SEARCH_URL).driver, status=self.statusMessage)
self.searcher = AmtrakSearch(self, Driver(cfg.SEARCH_URL, undetected=True).driver, status=self.statusMessage)

if __name__ == "__main__":
app = MainWindow()
Expand Down
8 changes: 5 additions & 3 deletions searcher/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
import undetected_chromedriver as uc

if os.name == 'nt':
LOG_PATH = 'NUL'
Expand All @@ -22,7 +23,7 @@ class Driver:
----------
driver : WebDriver
"""
def __init__(self, url="about:blank"):
def __init__(self, url="about:blank", undetected=False):
"""
Initializes the webdriver and downloads one if necessary.
Expand All @@ -33,10 +34,11 @@ def __init__(self, url="about:blank"):
"""
# Chrome options to disable logging in terminal
chrome_options = Options()
#chrome_options.add_argument("--headless")
chrome_options.add_argument("--headless")
chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"])
try:
self.driver = webdriver.Chrome(ChromeDriverManager().install(),service_log_path=LOG_PATH, options=chrome_options)
if undetected: self.driver = uc.Chrome(executable_path=ChromeDriverManager().install(), service_log_path=LOG_PATH)
else: self.driver = webdriver.Chrome(ChromeDriverManager().install(),service_log_path=LOG_PATH, options=chrome_options)
self.driver.maximize_window()
self.driver.get(url)
except WebDriverException:
Expand Down

0 comments on commit 6ba22be

Please sign in to comment.