Skip to content

Commit

Permalink
Merge branch 'SeleniumHQ:trunk' into trunk
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Dec 8, 2023
2 parents 745b94c + 3e19181 commit 6ca7e06
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 13 deletions.
10 changes: 10 additions & 0 deletions charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,16 @@ http://{{- if eq .Values.basicAuth.enabled true}}{{ .Values.basicAuth.username}}
{{- end }}
{{- end -}}

{{- define "seleniumGrid.url.subPath" -}}
{{- $subPath := "/" -}}
{{ if $.Values.isolateComponents }}
{{- $subPath = default $subPath $.Values.components.subPath -}}
{{- else -}}
{{- $subPath = default $subPath $.Values.hub.subPath -}}
{{- end -}}
{{ $subPath }}
{{- end -}}

{{/*
Graphql Url of the hub or the router
*/}}
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/templates/node-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ metadata:
{{- end }}
data:
SE_DRAIN_AFTER_SESSION_COUNT: '{{- and (eq (include "seleniumGrid.useKEDA" .) "true") (eq .Values.autoscaling.scalingType "job") | ternary "1" "0" -}}'
SE_NODE_GRID_URL: '{{ include "seleniumGrid.url" .}}'
SE_NODE_GRID_URL: '{{ include "seleniumGrid.url" .}}{{ include "seleniumGrid.url.subPath" .}}'
28 changes: 16 additions & 12 deletions tests/SeleniumTests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,22 @@ def test_play_video(self):

def test_download_file(self):
driver = self.driver
driver.get('https://demoqa.com/upload-download')
file_name = 'sampleFile.jpeg'
wait = WebDriverWait(driver, 30)
file_link = wait.until(
EC.element_to_be_clickable((By.XPATH, f'//*[@download="{file_name}"]'))
)
file_link.click()
wait.until(
lambda d: str(d.get_downloadable_files()[0]).endswith(file_name)
)
sleep(5)
self.assertTrue(str(driver.get_downloadable_files()[0]).endswith(file_name))
driver.get('https://the-internet.herokuapp.com/download')
file_name = 'some-file.txt'
is_continue = True
try:
wait = WebDriverWait(driver, 30)
file_link = wait.until(
EC.element_to_be_clickable((By.LINK_TEXT, file_name))
)
except:
is_continue = False
if is_continue:
file_link.click()
wait.until(
lambda d: str(d.get_downloadable_files()[0]).endswith(file_name)
)
self.assertTrue(str(driver.get_downloadable_files()[0]).endswith(file_name))

def tearDown(self):
self.driver.quit()
Expand Down
3 changes: 3 additions & 0 deletions tests/charts/templates/render/dummy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ ingress:

isolateComponents: true

components:
subPath: *gridAppRoot

chromeNode:
affinity: *affinity

Expand Down
22 changes: 22 additions & 0 deletions tests/charts/templates/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@ def test_ingress_nginx_annotations(self):
count += 1
self.assertEqual(count, len(resources_name), "No ingress resources found")

def test_sub_path_append_to_node_grid_url(self):
resources_name = ['selenium-node-config']
count = 0
for doc in LIST_OF_DOCUMENTS:
if doc['metadata']['name'] in resources_name and doc['kind'] == 'ConfigMap':
logger.info(f"Assert subPath is appended to node grid url")
self.assertTrue(doc['data']['SE_NODE_GRID_URL'] == 'http://admin:[email protected]:4444/selenium')
count += 1
self.assertEqual(count, len(resources_name), "No node config resources found")

def test_sub_path_set_to_grid_env_var(self):
resources_name = ['selenium-router']
is_present = False
for doc in LIST_OF_DOCUMENTS:
if doc['metadata']['name'] in resources_name and doc['kind'] == 'Deployment':
logger.info(f"Assert subPath is set to grid ENV variable")
list_env = doc['spec']['template']['spec']['containers'][0]['env']
for env in list_env:
if env['name'] == 'SE_SUB_PATH' and env['value'] == '/selenium':
is_present = True
self.assertTrue(is_present, "ENV variable SE_SUB_PATH is not populated")

if __name__ == '__main__':
failed = False
try:
Expand Down

0 comments on commit 6ca7e06

Please sign in to comment.