#!/usr/bin/env python3 # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://mozilla.org/MPL/2.0/. import os import random import tempfile import time from basic_tests import SnapTestsBase from selenium.common.exceptions import StaleElementReferenceException, TimeoutException from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.select import Select class QATests(SnapTestsBase): def __init__(self): self._dir = "qa_tests" super(QATests, self).__init__( exp=os.path.join(self._dir, "qa_expectations.json") ) def _test_audio_playback( self, url, iframe_selector=None, click_to_play=False, video_selector=None ): self._logger.info("open url {}".format(url)) if url: self.open_tab(url) if iframe_selector: self._logger.info("find iframe") iframe = self._driver.find_element(By.CSS_SELECTOR, iframe_selector) self._driver.switch_to.frame(iframe) self._logger.info("find video") video = self._wait.until( EC.visibility_of_element_located( (By.CSS_SELECTOR, video_selector or "video") ) ) self._wait.until(lambda d: type(video.get_property("duration")) == float) assert video.get_property("duration") > 0.0, "