Skip to content

Commit

Permalink
make selenium tests use webdriver-manager and not use automation flag
Browse files Browse the repository at this point in the history
  • Loading branch information
kaliiiiiiiiii committed Apr 16, 2024
1 parent a4100f4 commit d022a79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ automation_linting =
botright
selenium
selenium_driverless
webdriver-manager
testing =
pytest
mypy
Expand All @@ -53,3 +54,4 @@ testing =
botright
selenium
selenium_driverless
webdriver-manager
15 changes: 10 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import pytest
import pytest_asyncio
from webdriver_manager.chrome import ChromeDriverManager
from selenium import webdriver as selenium_webdriver
from selenium.webdriver.chrome.service import Service as SeleniumChromeService
from playwright.async_api import Page as AsyncPage
from playwright.async_api import async_playwright
from playwright.sync_api import Page as SyncPage
Expand Down Expand Up @@ -133,15 +135,18 @@ def sync_driver() -> Generator[sync_webdriver.Chrome, None, None]:
@pytest.fixture
def selenium_driver() -> Generator[selenium_webdriver.Chrome, None, None]:
options = selenium_webdriver.ChromeOptions()
for flag in flags:
options.add_argument(flag)

# disable logs
options.add_experimental_option('excludeSwitches', ['enable-logging'])
# disable logs & automation
options.add_experimental_option('excludeSwitches', ['enable-logging', "enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument("--log-level=3")

for flag in flags:
options.add_argument(flag)
# start url at about:blank
options.add_argument("about:blank")

with selenium_webdriver.Chrome(options) as driver:
with selenium_webdriver.Chrome(options,service=SeleniumChromeService(ChromeDriverManager().install())) as driver:
driver.sync_input = SyncInput(browser=driver)
yield driver

Expand Down

0 comments on commit d022a79

Please sign in to comment.