| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
import pytest |
| 19 |
|
| 20 |
from selenium.webdriver.common.options import PageLoadStrategy |
| 21 |
from selenium.webdriver.edge.options import Options |
| 22 |
|
| 23 |
|
| 24 |
@pytest.fixture |
| 25 |
def options(): |
| 26 |
return Options() |
| 27 |
|
| 28 |
|
| 29 |
def test_raises_exception_with_invalid_page_load_strategy(options): |
| 30 |
with pytest.raises(ValueError): |
| 31 |
options.page_load_strategy = "never" |
| 32 |
|
| 33 |
|
| 34 |
def test_set_page_load_strategy(options): |
| 35 |
options.page_load_strategy = PageLoadStrategy.normal |
| 36 |
caps = options.to_capabilities() |
| 37 |
assert caps["pageLoadStrategy"] == PageLoadStrategy.normal |
| 38 |
|
| 39 |
|
| 40 |
def test_get_page_load_strategy(options): |
| 41 |
options._caps["pageLoadStrategy"] = PageLoadStrategy.normal |
| 42 |
assert options.page_load_strategy == PageLoadStrategy.normal |
| 43 |
|
| 44 |
|
| 45 |
def test_creates_capabilities(options): |
| 46 |
options.page_load_strategy = PageLoadStrategy.eager |
| 47 |
caps = options.to_capabilities() |
| 48 |
assert caps["pageLoadStrategy"] == PageLoadStrategy.eager |
| 49 |
|
| 50 |
|
| 51 |
def test_starts_with_default_capabilities(options): |
| 52 |
from selenium.webdriver import DesiredCapabilities |
| 53 |
|
| 54 |
caps = DesiredCapabilities.EDGE.copy() |
| 55 |
caps.update({"pageLoadStrategy": PageLoadStrategy.normal}) |
| 56 |
assert options._caps == caps |
| 57 |
|
| 58 |
|
| 59 |
def test_is_a_baseoptions(options): |
| 60 |
from selenium.webdriver.common.options import BaseOptions |
| 61 |
|
| 62 |
assert isinstance(options, BaseOptions) |
| 63 |
|
| 64 |
|
| 65 |
def test_use_webview(): |
| 66 |
options = Options() |
| 67 |
options.use_webview = True |
| 68 |
caps = options.to_capabilities() |
| 69 |
assert caps["browserName"] == "webview2" |