Skip to content

Commit

Permalink
test: Add sanity test for download file (#2034) [deploy]
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
VietND96 committed Nov 29, 2023
1 parent b5dab36 commit 991d245
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 3 deletions.
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 | &check; |
| | Sanity tests in node | &check; |
| | Video recorder is enabled in node | &cross; |
| | Node `extraEnvironmentVariables` is set value | &check; |

## 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

0 comments on commit 991d245

Please sign in to comment.