From f51c0263a5ca0f781357d676b090de7602f6b325 Mon Sep 17 00:00:00 2001 From: Alvar Penning Date: Sat, 30 Apr 2022 11:56:00 +0200 Subject: [PATCH] stream.py: fix selenium deprecation warnings - webdriver.Chrome: a Service should be used over the executable_path[0] - find_element_*: a By selector in find_element should be used[1] [0] https://github.com/SeleniumHQ/selenium/blob/selenium-4.1.3-python/py/CHANGES#L159 [1] https://github.com/SeleniumHQ/selenium/blob/selenium-4.1.3-python/py/CHANGES#L90 --- stream.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/stream.py b/stream.py index cbcc1be..e82c03a 100644 --- a/stream.py +++ b/stream.py @@ -6,11 +6,13 @@ from bigbluebutton_api_python import BigBlueButton, exception from bigbluebutton_api_python import util as bbbUtil from selenium import webdriver +from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import ElementClickInterceptedException from selenium.common.exceptions import JavascriptException from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.chrome.options import Options +from selenium.webdriver.chrome.service import Service from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By @@ -137,7 +139,7 @@ def set_up(): logging.info('Starting browser!!') - browser = webdriver.Chrome(executable_path='./chromedriver',options=options) + browser = webdriver.Chrome(service=Service('./chromedriver'), options=options) def bbb_browser(): global browser @@ -160,8 +162,8 @@ def bbb_browser(): element = EC.presence_of_element_located((By.ID, 'message-input')) WebDriverWait(browser, selenium_timeout).until(element) - element = browser.find_element_by_id('message-input') - chat_send = browser.find_elements_by_css_selector('[aria-label="Send message"]')[0] + element = browser.find_element(By.ID, 'message-input') + chat_send = browser.find_elements(By.CSS_SELECTOR, '[aria-label="Send message"]')[0] # ensure chat is enabled (might be locked by moderator) if element.is_enabled() and chat_send.is_enabled(): tmp_chatMsg = os.environ.get('BBB_CHAT_MESSAGE', "This meeting is streamed to") @@ -188,7 +190,7 @@ def bbb_browser(): except JavaScriptException: browser.execute_script("document.querySelector('[aria-label=\"Users list\"]').parentElement.style.display='none';") else: - element = browser.find_elements_by_id('chat-toggle-button')[0] + element = browser.find_elements(By.ID, 'chat-toggle-button')[0] if element.is_enabled(): element.click() except NoSuchElementException: @@ -201,7 +203,7 @@ def bbb_browser(): time.sleep(10) if not args.chat: try: - element = browser.find_elements_by_css_selector('button[aria-label^="Users and messages toggle"]')[0] + element = browser.find_elements(By.CSS_SELECTOR, 'button[aria-label^="Users and messages toggle"]')[0] if element.is_enabled(): element.click() except NoSuchElementException: