Skip to content

Commit

Permalink
fix: video container wait capabilities fully before extracting details
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 Sep 10, 2024
1 parent a545d08 commit af5f36e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ test_video_standalone: standalone_chrome standalone_chromium standalone_firefox
DOCKER_COMPOSE_FILE=docker-compose-v3-test-standalone.yml TEST_DELAY_AFTER_TEST=2 HUB_CHECKS_INTERVAL=45 make test_video

test_video_dynamic_name:
VIDEO_FILE_NAME=auto TEST_DELAY_AFTER_TEST=2 HUB_CHECKS_INTERVAL=45 \
VIDEO_FILE_NAME=auto TEST_DELAY_AFTER_TEST=2 HUB_CHECKS_INTERVAL=45 TEST_ADD_CAPS_RECORD_VIDEO=false \
make test_video

# This should run on its own CI job. There is no need to combine it with the other tests.
Expand Down Expand Up @@ -674,6 +674,7 @@ test_video: video hub chrome firefox edge chromium
echo BASIC_AUTH_USERNAME=$(or $(BASIC_AUTH_USERNAME), "admin") >> .env ; \
echo BASIC_AUTH_PASSWORD=$(or $(BASIC_AUTH_PASSWORD), "admin") >> .env ; \
echo SUB_PATH=$(or $(SUB_PATH), "/selenium") >> .env ; \
echo TEST_ADD_CAPS_RECORD_VIDEO=$(or $(TEST_ADD_CAPS_RECORD_VIDEO), "true") >> .env ; \
if [ $$node = "NodeChrome" ] ; then \
echo BROWSER=chrome >> .env ; \
echo VIDEO_FILE_NAME=$${VIDEO_FILE_NAME:-"chrome_video.mp4"} >> .env ; \
Expand Down
2 changes: 1 addition & 1 deletion Video/video_graphQLQuery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if [ -n "${GRAPHQL_ENDPOINT}" ]; then
# Check if the response contains "capabilities"
if [[ "$endpoint_checks" = "404" ]] || [[ $current_check -eq $retry_time ]]; then
break
elif [[ "$endpoint_checks" = "200" ]] && [[ $(jq -e '.data.session.capabilities' /tmp/graphQL_${SESSION_ID}.json >/dev/null) -eq 0 ]]; then
elif [[ "$endpoint_checks" = "200" ]] && [[ $(jq -e '.data.session.capabilities | fromjson | ."'browserName'"' /tmp/graphQL_${SESSION_ID}.json >/dev/null) -eq 0 ]]; then
break
fi
done
Expand Down
10 changes: 7 additions & 3 deletions tests/SeleniumTests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
TEST_ANDROID_PLATFORM_API = os.environ.get('ANDROID_PLATFORM_API')
TEST_PLATFORMS = os.environ.get('TEST_PLATFORMS', 'linux/amd64')
TEST_FIREFOX_INSTALL_LANG_PACKAGE = os.environ.get('TEST_FIREFOX_INSTALL_LANG_PACKAGE', 'false').lower() == 'true'
TEST_ADD_CAPS_RECORD_VIDEO = os.environ.get('TEST_ADD_CAPS_RECORD_VIDEO', 'true').lower() == 'true'

if SELENIUM_GRID_USERNAME and SELENIUM_GRID_PASSWORD:
SELENIUM_GRID_HOST = f"{SELENIUM_GRID_USERNAME}:{SELENIUM_GRID_PASSWORD}@{SELENIUM_GRID_HOST}"
Expand Down Expand Up @@ -129,7 +130,8 @@ def setUp(self):
options = ChromeOptions()
options.enable_downloads = SELENIUM_ENABLE_MANAGED_DOWNLOADS
options.add_argument('disable-features=DownloadBubble,DownloadBubbleV2')
options.set_capability('se:recordVideo', True)
if TEST_ADD_CAPS_RECORD_VIDEO:
options.set_capability('se:recordVideo', True)
options.set_capability('se:name', f"{self._testMethodName} ({self.__class__.__name__})")
options.set_capability('se:screenResolution', '1920x1080')
if SELENIUM_GRID_TEST_HEADLESS:
Expand Down Expand Up @@ -165,7 +167,8 @@ def setUp(self):
options = EdgeOptions()
options.enable_downloads = SELENIUM_ENABLE_MANAGED_DOWNLOADS
options.add_argument('disable-features=DownloadBubble,DownloadBubbleV2')
options.set_capability('se:recordVideo', True)
if TEST_ADD_CAPS_RECORD_VIDEO:
options.set_capability('se:recordVideo', True)
options.set_capability('se:name', f"{self._testMethodName} ({self.__class__.__name__})")
options.set_capability('se:screenResolution', '1920x1080')
if SELENIUM_GRID_TEST_HEADLESS:
Expand Down Expand Up @@ -193,7 +196,8 @@ def setUp(self):
options = FirefoxOptions()
options.profile = profile
options.enable_downloads = SELENIUM_ENABLE_MANAGED_DOWNLOADS
options.set_capability('se:recordVideo', True)
if TEST_ADD_CAPS_RECORD_VIDEO:
options.set_capability('se:recordVideo', True)
options.set_capability('se:name', f"{self._testMethodName} ({self.__class__.__name__})")
options.set_capability('se:screenResolution', '1920x1080')
if SELENIUM_GRID_TEST_HEADLESS:
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 @@ -81,4 +81,5 @@ services:
- SELENIUM_ENABLE_MANAGED_DOWNLOADS=${SELENIUM_ENABLE_MANAGED_DOWNLOADS}
- TEST_FIREFOX_INSTALL_LANG_PACKAGE=${TEST_FIREFOX_INSTALL_LANG_PACKAGE}
- HUB_CHECKS_INTERVAL=${HUB_CHECKS_INTERVAL}
- TEST_ADD_CAPS_RECORD_VIDEO=${TEST_ADD_CAPS_RECORD_VIDEO}
command: ["/bin/bash", "-c", "./bootstrap.sh ${NODE}"]

0 comments on commit af5f36e

Please sign in to comment.