Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add sanity test for download file #2034

Merged
merged 2 commits into from
Nov 29, 2023
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
![Build & test](https://github.com/SeleniumHQ/docker-selenium/workflows/Build%20&%20test/badge.svg?branch=trunk)
![Deployments](https://github.com/SeleniumHQ/docker-selenium/workflows/Deploys/badge.svg)
![Helm Charts](https://github.com/SeleniumHQ/docker-selenium/workflows/Lint%20and%20Test%20Helm%20Charts/badge.svg)

# Docker images for the Selenium Grid Server

Expand Down
1 change: 1 addition & 0 deletions charts/selenium-grid/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ All related testing to this helm chart will be documented in this file.
| Browser Nodes | Node `nameOverride` is set | ✓ |
| | Sanity tests in node | ✓ |
| | Video recorder is enabled in node | ✗ |
| | Node `extraEnvironmentVariables` is set value | ✓ |

## Build & test Docker images with Helm charts
Noted: These `make` commands are composed and tested on Linux x86_64.
Expand Down
3 changes: 3 additions & 0 deletions charts/selenium-grid/ci/NodeChrome-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Configuration for chrome nodes
chromeNode:
nameOverride: my-chrome-name
extraEnvironmentVariables:
- name: SE_OPTS
value: "--enable-managed-downloads true"
# Configuration for edge nodes
edgeNode:
enabled: false
Expand Down
3 changes: 3 additions & 0 deletions charts/selenium-grid/ci/NodeEdge-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ chromeNode:
# Configuration for edge nodes
edgeNode:
nameOverride: my-edge-name
extraEnvironmentVariables:
- name: SE_OPTS
value: "--enable-managed-downloads true"
# Configuration for firefox nodes
firefoxNode:
enabled: false
3 changes: 3 additions & 0 deletions charts/selenium-grid/ci/NodeFirefox-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ edgeNode:
# Configuration for firefox nodes
firefoxNode:
nameOverride: my-firefox-name
extraEnvironmentVariables:
- name: SE_OPTS
value: "--enable-managed-downloads true"
25 changes: 22 additions & 3 deletions tests/SeleniumTests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,48 @@ def test_play_video(self):
paused = video.get_property('paused')
self.assertFalse(paused)

def test_download_file(self):
driver = self.driver
driver.get('https://the-internet.herokuapp.com/download')
wait = WebDriverWait(driver, 30)
file_link = wait.until(
EC.element_to_be_clickable((By.LINK_TEXT, 'some-file.txt'))
)
file_link.click()
wait.until(
lambda d: len(d.get_downloadable_files()) > 0
)
self.assertTrue(len(driver.get_downloadable_files()) > 0)

def tearDown(self):
self.driver.quit()


class ChromeTests(SeleniumGenericTests):
def setUp(self):
options = ChromeOptions()
options.enable_downloads = True
self.driver = webdriver.Remote(
options=ChromeOptions(),
options=options,
command_executor="http://%s:%s" % (SELENIUM_GRID_HOST,SELENIUM_GRID_PORT)
)

class EdgeTests(SeleniumGenericTests):
def setUp(self):
options = EdgeOptions()
options.enable_downloads = True
self.driver = webdriver.Remote(
options=EdgeOptions(),
options=options,
command_executor="http://%s:%s" % (SELENIUM_GRID_HOST,SELENIUM_GRID_PORT)
)


class FirefoxTests(SeleniumGenericTests):
def setUp(self):
options = FirefoxOptions()
options.enable_downloads = True
self.driver = webdriver.Remote(
options=FirefoxOptions(),
options=options,
command_executor="http://%s:%s" % (SELENIUM_GRID_HOST,SELENIUM_GRID_PORT)
)

Expand Down
1 change: 1 addition & 0 deletions tests/docker-compose-v3-test-video.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_OPTS=--enable-managed-downloads true
ports:
- "6900:5900"

Expand Down
2 changes: 2 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def launch_container(container, **kwargs):
'SE_EVENT_BUS_PUBLISH_PORT': 4442,
'SE_EVENT_BUS_SUBSCRIBE_PORT': 4443
}
if container != 'Hub':
environment['SE_OPTS'] = "--enable-managed-downloads true"
container_id = client.containers.run("%s/%s:%s" % (NAMESPACE, IMAGE_NAME_MAP[container], VERSION),
detach=True,
environment=environment,
Expand Down