From ddaf34a475291f1e291b88d17249c9653ba39f9e Mon Sep 17 00:00:00 2001 From: cruizba Date: Fri, 5 Nov 2021 15:33:46 +0100 Subject: [PATCH] deployment: openvidu_health_check - fix error when 'about:webrtc' page refresh its data --- .../docker/openvidu-health-checker/Dockerfile | 2 +- .../openvidu_health_check.py | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openvidu-server/docker/openvidu-health-checker/Dockerfile b/openvidu-server/docker/openvidu-health-checker/Dockerfile index d3fa9523..5e3d585a 100644 --- a/openvidu-server/docker/openvidu-health-checker/Dockerfile +++ b/openvidu-server/docker/openvidu-health-checker/Dockerfile @@ -21,7 +21,7 @@ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key google-chrome-stable firefox \ && rm /etc/apt/sources.list.d/google-chrome.list -RUN pip3 install selenium webdriver_manager prettytable +RUN pip3 install selenium webdriver_manager prettytable beautifulsoup4 WORKDIR /workdir diff --git a/openvidu-server/docker/openvidu-health-checker/openvidu_health_check.py b/openvidu-server/docker/openvidu-health-checker/openvidu_health_check.py index 3cc83ee5..8b8a5707 100644 --- a/openvidu-server/docker/openvidu-health-checker/openvidu_health_check.py +++ b/openvidu-server/docker/openvidu-health-checker/openvidu_health_check.py @@ -11,6 +11,7 @@ from selenium.webdriver.chrome.service import Service as ChromeService from selenium.webdriver.firefox.service import Service as FirefoxService from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By +from bs4 import BeautifulSoup from prettytable import from_html_one import time import os @@ -94,9 +95,7 @@ class InfraSmokeTests(unittest.TestCase): if video_error == True: raise Exception('Error. No video detected') - time.sleep(3) self.driver.switch_to.window(self.driver.window_handles[0]) - time.sleep(3) elem = self.driver.find_element(By.ID,'test-btn') elem.send_keys(Keys.RETURN) @@ -169,16 +168,17 @@ class InfraSmokeTests(unittest.TestCase): print("Waiting for candidates to be checked...") # Get ice stats time.sleep(15) - ice_stats_div_elems = self.driver.find_elements(By.XPATH, "//div[contains(@id, 'ice-stats')]") - for ice_stats_div in ice_stats_div_elems: - table_elems = ice_stats_div.find_elements(By.TAG_NAME, 'table') - ice_candidates_table = table_elems[0] - html_ice_table = '' + ice_candidates_table.get_attribute('innerHTML') + '
' - print(from_html_one(html_ice_table)) - # Go to main window + # about:webrtc page refreshes each second, so we need to + # safe the entire HTML in a variable to have a Snapshot of the situation + about_webrtc_html = '' + self.driver.find_element(By.TAG_NAME, 'html').get_attribute('innerHTML') + '' + # Search the tables using a parser and print all candidates + soup = BeautifulSoup(about_webrtc_html, 'html.parser') + for caption in soup.findAll('caption', {'data-l10n-id' : 'about-webrtc-trickle-caption-msg'}): + print(from_html_one(str(caption.parent))) + # Close about:webrtc self.driver.close() except: - pass + print('[Warn] Some candidates may not appear in test result') def closeBrowser(self): # close the browser window