Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
fail-fast: false
matrix:
include:
- browser: firefox
- browser: chrome
with:
name: Integration Tests (remote, ${{ matrix.browser }})
browser: ${{ matrix.browser }}
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ namespace :py do
end
end

desc 'Python Remote tests with Firefox'
desc 'Python Remote tests with Chrome'
task :remote do
Rake::Task['py:clean'].invoke
Bazel.execute('test', [], '//py:test-remote')
Expand Down
6 changes: 3 additions & 3 deletions py/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class SupportedOptions(ContainerProtocol):
edge: str = "EdgeOptions"
safari: str = "SafariOptions"
ie: str = "IeOptions"
remote: str = "FirefoxOptions"
remote: str = "ChromeOptions"
webkitgtk: str = "WebKitGTKOptions"
wpewebkit: str = "WPEWebKitOptions"

Expand Down Expand Up @@ -249,8 +249,8 @@ def options(self, cls_name):
# under Wayland, so we use XWayland instead.
os.environ["MOZ_ENABLE_WAYLAND"] = "0"
elif self.driver_class == self.supported_drivers.remote:
self._options = getattr(webdriver, self.supported_options.firefox)()
self._options.set_capability("moz:firefoxOptions", {})
self._options = getattr(webdriver, self.supported_options.chrome)()
self._options.set_capability("goog:chromeOptions", {})
self._options.enable_downloads = True
else:
opts_cls = getattr(self.supported_options, cls_name.lower())
Expand Down
15 changes: 8 additions & 7 deletions py/test/selenium/webdriver/common/api_example_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,20 @@ def test_move_window_position(driver, pages):
assert loc["y"] == new_y


@pytest.mark.xfail_edge(reason="Window does not resize")
@pytest.mark.xfail_edge(reason="Window sometimes does not resize")
@pytest.mark.xfail_remote(reason="Window sometimes does not resize")
def test_change_window_size(driver, pages):
pages.load("blank.html")
size = driver.get_window_size()
newSize = [600, 600]
new_size = [600, 600]
if size["width"] == 600:
newSize[0] = 500
new_size[0] = 500
if size["height"] == 600:
newSize[1] = 500
driver.set_window_size(newSize[0], newSize[1])
new_size[1] = 500
driver.set_window_size(new_size[0], new_size[1])
size = driver.get_window_size()
assert size["width"] == newSize[0]
assert size["height"] == newSize[1]
assert size["width"] == new_size[0]
assert size["height"] == new_size[1]


@pytest.mark.xfail_ie(raises=AttributeError, reason="Logging API is no longer available")
Expand Down
24 changes: 13 additions & 11 deletions py/test/selenium/webdriver/remote/remote_connection_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@
from selenium.webdriver.remote.client_config import ClientConfig


def test_browser_specific_method(driver, pages):
def test_browser_specific_method(firefox_options, webserver):
"""This only works on Firefox"""
pages.load("simpleTest.html")
screenshot = driver.execute("FULL_PAGE_SCREENSHOT")["value"]
result = base64.b64decode(screenshot)
kind = filetype.guess(result)
assert kind is not None and kind.mime == "image/png"
server_addr = f"http://{webserver.host}:{webserver.port}"
with webdriver.Remote(options=firefox_options) as driver:
driver.get(f"{server_addr}/simpleTest.html")
screenshot = driver.execute("FULL_PAGE_SCREENSHOT")["value"]
result = base64.b64decode(screenshot)
kind = filetype.guess(result)
assert kind is not None and kind.mime == "image/png"


def test_remote_webdriver_with_http_timeout(firefox_options, webserver):
def test_remote_webdriver_with_http_timeout(chromium_options, webserver):
"""This test starts a remote webdriver with an http client timeout
set less than the implicit wait timeout, and verifies the http timeout
is triggered first when waiting for an element.
Expand All @@ -46,14 +48,14 @@ def test_remote_webdriver_with_http_timeout(firefox_options, webserver):
server_addr = f"http://{webserver.host}:{webserver.port}"
client_config = ClientConfig(remote_server_addr=server_addr, timeout=http_timeout)
assert client_config.timeout == http_timeout
with webdriver.Remote(options=firefox_options, client_config=client_config) as driver:
with webdriver.Remote(options=chromium_options, client_config=client_config) as driver:
driver.get(f"{server_addr}/simpleTest.html")
driver.implicitly_wait(wait_timeout)
with pytest.raises(ReadTimeoutError):
driver.find_element(By.ID, "no_element_to_be_found")


def test_remote_webdriver_with_websocket_timeout(firefox_options, webserver):
def test_remote_webdriver_with_websocket_timeout(chromium_options, webserver):
"""This test starts a remote webdriver that uses websockets, and has a websocket
client timeout less than the default. It verifies the websocket times out according
to this value.
Expand All @@ -66,8 +68,8 @@ def test_remote_webdriver_with_websocket_timeout(firefox_options, webserver):
remote_server_addr=server_addr, websocket_timeout=websocket_timeout, websocket_interval=websocket_interval
)
assert client_config.websocket_timeout == websocket_timeout
firefox_options.enable_bidi = True
with webdriver.Remote(options=firefox_options, client_config=client_config) as driver:
chromium_options.enable_bidi = True
with webdriver.Remote(options=chromium_options, client_config=client_config) as driver:
driver._start_bidi()
assert driver._websocket_connection.response_wait_timeout == websocket_timeout
assert driver._websocket_connection.response_wait_interval == websocket_interval
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def convert(self, by, value):


@pytest.fixture()
def custom_locator_driver(firefox_options):
driver = webdriver.Remote(options=firefox_options, locator_converter=CustomLocatorConverter())
def custom_locator_driver(chromium_options):
driver = webdriver.Remote(options=chromium_options, locator_converter=CustomLocatorConverter())
yield driver
driver.quit()

Expand Down
28 changes: 21 additions & 7 deletions py/test/selenium/webdriver/remote/remote_downloads_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,36 @@
import os
import tempfile

import pytest

from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait


@pytest.mark.no_driver_after_test
def test_get_downloadable_files(driver, pages):
_browser_downloads(driver, pages)

file_names = driver.get_downloadable_files()

assert "file_1.txt" in file_names
assert "file_2.jpg" in file_names
# TODO: why is Chrome downloading files as .html???
# assert "file_1.txt" in file_names
# assert "file_2.jpg" in file_names
assert any(f in file_names for f in ("file_1.txt", "file_1.htm", "file_1.html"))
assert any(f in file_names for f in ("file_2.jpg", "file_2.htm", "file_2.html"))
assert type(file_names) is list


@pytest.mark.no_driver_after_test
def test_download_file(driver, pages):
_browser_downloads(driver, pages)

# Get a list of downloadable files and find the txt file
downloadable_files = driver.get_downloadable_files()
text_file_name = next((file for file in downloadable_files if file.endswith(".txt")), None)
assert text_file_name is not None, "Could not find a .txt file in downloadable files"
# TODO: why is Chrome downloading files as .html???
# text_file_name = next((file for file in downloadable_files if file.endswith(".txt")), None)
text_file_name = next(
(f for f in downloadable_files if all((f.endswith((".txt", ".htm", ".html")), f.startswith("file_1")))), None
)
assert text_file_name is not None, "Could not find file in downloadable files"

with tempfile.TemporaryDirectory() as target_directory:
driver.download_file(text_file_name, target_directory)
Expand All @@ -48,6 +57,7 @@ def test_download_file(driver, pages):
assert "Hello, World!" in file.read()


@pytest.mark.no_driver_after_test
def test_delete_downloadable_files(driver, pages):
_browser_downloads(driver, pages)

Expand All @@ -59,4 +69,8 @@ def _browser_downloads(driver, pages):
pages.load("downloads/download.html")
driver.find_element(By.ID, "file-1").click()
driver.find_element(By.ID, "file-2").click()
WebDriverWait(driver, 3).until(lambda d: "file_2.jpg" in d.get_downloadable_files())
# TODO: why is Chrome downloading files as .html???
# WebDriverWait(driver, 5).until(lambda d: "file_2.jpg" in d.get_downloadable_files())
WebDriverWait(driver, 5).until(
lambda d: any(f in d.get_downloadable_files() for f in ("file_2.jpg", "file_2.htm", "file_2.html"))
)