-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from mreiche/feature/webdriver-detection
Feature/webdriver detection
- Loading branch information
Showing
6 changed files
with
87 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import inject | ||
import pytest | ||
|
||
from paf.control import change | ||
from paf.manager import WebDriverManager | ||
from paf.page import PageFactory, FinderPage | ||
from test import create_webdriver | ||
|
||
|
||
@pytest.fixture | ||
def finder(): | ||
page_factory = inject.instance(PageFactory) | ||
finder = page_factory.create_page(FinderPage, create_webdriver()) | ||
yield finder | ||
|
||
|
||
def test_typespeed(finder: FinderPage): | ||
finder.open("https://monkeytype.com") | ||
|
||
input_container = finder.find("#wordsInput") | ||
words_container = finder.find("#words") | ||
|
||
active_word = words_container.find(".active") | ||
|
||
with change(wait_after_fail=3): | ||
while active_word.wait_for.displayed(True): | ||
word = active_word.expect.text.actual | ||
input_container.send_keys(word) | ||
input_container.send_keys(" ") | ||
|
||
|
||
def teardown_module(): | ||
inject.instance(WebDriverManager).shutdown_all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import inject | ||
import pytest | ||
from selenium.webdriver import ChromeOptions | ||
|
||
from paf.manager import WebDriverManager | ||
from paf.request import WebDriverRequest | ||
from test import create_webdriver | ||
|
||
|
||
def test_detect_webdriver(): | ||
request = WebDriverRequest("automated") | ||
request.browser = "chrome" | ||
webdriver = create_webdriver(request) | ||
result = webdriver.execute_script("return navigator.webdriver") | ||
assert result is True | ||
|
||
|
||
@pytest.mark.skip(reason="Does not work in test image") | ||
def test_hide_webdriver(): | ||
request = WebDriverRequest("non-automated") | ||
request.browser = "chrome" | ||
options = ChromeOptions() | ||
options.add_argument("--disable-blink-features=AutomationControlled") | ||
request.options = options | ||
webdriver = create_webdriver(request) | ||
result = webdriver.execute_script("return navigator.webdriver") | ||
assert result is False | ||
|
||
|
||
def teardown_module(): | ||
inject.instance(WebDriverManager).shutdown_all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters