示例#1
0
    def run_once(self, device_ip):
        """Run the test code.

        @param  device_ip: Device IP to use in the test.
        """
        logging.info('Download Cast extension ... ...')
        crx_file = tempfile.NamedTemporaryFile(dir=self._tmp_folder,
                                               suffix='.crx').name
        unzip_crx_folder = tempfile.mkdtemp(dir=self._tmp_folder)
        self._download_extension_crx(crx_file)
        self._unzip_file(crx_file, unzip_crx_folder)
        self._modify_manifest(unzip_crx_folder)
        kwargs = {'extension_paths': [unzip_crx_folder]}
        with chromedriver.chromedriver(**kwargs) as chromedriver_instance:
            driver = chromedriver_instance.driver
            extension_id = chromedriver_instance.get_extension(
                unzip_crx_folder).extension_id
            # Close popup dialog if there is any
            self._close_popup_tabs(driver)
            self._block_setup_dialog(driver, extension_id)
            time.sleep(WAIT_SECONDS)
            logging.info('Enable TDLS in extension: %s', extension_id)
            self._turn_on_tdls(driver, extension_id)
            extension_tab_handle = driver.current_window_handle
            logging.info('Start mirroring on device: %s', device_ip)
            self._start_mirroring(driver, extension_id, device_ip, TEST_URL)
            time.sleep(MIRRORING_DURATION_SECONDS)
            self._set_focus_tab(driver, extension_tab_handle)
            driver.switch_to_window(extension_tab_handle)
            logging.info('Stop mirroring on device: %s', device_ip)
            self._stop_mirroring(driver, extension_id)
            time.sleep(WAIT_SECONDS * 3)
            logging.info(
                'Verify TDLS status in the mirroring session ... ... ')
            self._check_tdls_status(device_ip)
示例#2
0
 def run_once(self, **kwargs):
     with chromedriver.chromedriver(
             username=self.username,
             password=self.password,
             extra_chrome_flags=self._chrome_flags) \
             as chromedriver_instance:
         self.driver = chromedriver_instance.driver
         self.driver.implicitly_wait(15)
         self._wait = WebDriverWait(self.driver, 20)
         logging.info('Running test on test environment %s',
                      TestEnv.to_string[self.test_env])
         self.run(**kwargs)
 def run_once(self):
     """Run the test code."""
     # TODO: When we've cloned the sonic test repo get these from their
     # test config files.
     logging.info('Starting sonic client test.')
     kwargs = {
         'extension_paths': [self._extension_dir],
         'is_component': True,
         'extra_chrome_flags': [self._settings['extra_flags']],
     }
     with chromedriver.chromedriver(**kwargs) as chromedriver_instance:
         driver = chromedriver_instance.driver
         extension = chromedriver_instance.get_extension(
             self._extension_dir)
         extension_id = extension.extension_id
         time.sleep(self.wait_time)
         self._test_utils.close_popup_tabs(driver)
         self._test_utils.block_setup_dialog(driver, extension_id)
         test_info = self._get_run_information(driver, self._settings)
         logging.info('Starting tabcast to extension: %s', extension_id)
         self._test_utils.set_mirroring_options(driver, extension_id,
                                                self._settings)
         current_tab_handle = driver.current_window_handle
         self._test_utils.start_v2_mirroring_test_utils(
             driver, extension_id, self._sonic_hostname,
             self._settings['video_site'],
             self._settings['full_screen'] == 'on')
         self._test_utils.set_focus_tab(driver, current_tab_handle)
         driver.switch_to_window(current_tab_handle)
         cpu_usage = self._test_utils.cpu_usage_interval(
             int(self._settings['mirror_duration']))
         self._test_utils.stop_v2_mirroring_test_utils(driver, extension_id)
         crash_id = self._test_utils.upload_v2_mirroring_logs(
             driver, extension_id)
         test_info['crash_id'] = crash_id
         if self._settings.get('sender_root_dir'):
             cpu_bound = self._test_utils.compute_cpu_utilization(cpu_usage)
             info_json_file = os.path.join(
                 self._settings['sender_root_dir'], 'test_information.json')
             cpu_json_file = os.path.join(self._settings['sender_root_dir'],
                                          'cpu_data.json')
             cpu_bound_json_file = os.path.join(
                 self._settings['sender_root_dir'], 'cpu_bound.json')
             json.dump(test_info, open(info_json_file, 'wb'))
             json.dump(cpu_usage, open(cpu_json_file, 'wb'))
             json.dump(cpu_bound, open(cpu_bound_json_file, 'wb'))
         time.sleep(self.wait_time)
         #To cehck encoder acceleration used while casting
         histogram_verifier.verify(chromedriver_instance.chrome_instance,
                                   MEDIA_GVD_INIT_STATUS, MEDIA_GVD_BUCKET)
示例#4
0
    def run_once(self, iteration_count=3):
        """Turn on/off bluetooth through UI

        @param iteration_count: Number of iterations to toggle on/off

        """
        self.success = False
        with chromedriver.chromedriver() as chromedriver_instance:
            driver = chromedriver_instance.driver
            bt_page = self.bluetooth_page(driver)
            self.turn_off_bluetooth(bt_page)
            for iteration in xrange(1, iteration_count + 1):
                logging.info("**** Turn on/off BT iteration: %d ****",
                             iteration)
                self.turn_on_bluetooth(bt_page)
                self.turn_off_bluetooth(bt_page)
        self.success = True
示例#5
0
    def run_once(self):
        """Run the test code."""
        with chromedriver.chromedriver() as chromedriver_instance:
            driver = chromedriver_instance.driver
            driver.get(self._test_url)
            logging.info('Expected tab title: %s. Got: %s',
                         self._expected_title, driver.title)
            if driver.title != self._expected_title:
                raise error.TestError('Getting title failed, got title: %s' %
                                      driver.title)

            element = driver.find_element_by_id(self._element_id)
            element.clear()
            element.send_keys(self._text)
            entered_text = element.get_attribute("value")
            if entered_text != self._text:
                raise error.TestError('Value of text box %s, expected %s' %
                                      (self._text, entered_text))
示例#6
0
    def run_once(self):
        """Run the test code."""
        with chromedriver.chromedriver() as chromedriver_instance:
            driver = chromedriver_instance.driver
            driver.delete_all_cookies()
            driver.get(self._test_url)

            logging.info('Expected tab title: %s. Got: %s',
                         self._expected_title, driver.title)
            if driver.title != self._expected_title:
                raise error.TestError('Getting title failed, got title: %s' %
                                      driver.title)

            cookie_found = any([
                cookie for cookie in driver.get_cookies()
                if cookie['domain'] == self._domain
            ])
            if not cookie_found:
                raise error.TestError('Expected cookie for %s' %
                                      self._test_url)
    def run_once(self, username=None, password=None, source="Downloads",
                 file_name='test.dat'):
        """Copy file to Google Drive in Files application

        @param username: Real user(Not default autotest user)
        @param password: Password for the user.
        @param source: From where to copy file
        @param file_name: File name
        """
        self.success = False  # Used to capture the screenshot if the TC fails
        with chromedriver.chromedriver(username=username,
                                       password=password,
                                       disable_default_apps=False,
                                       gaia_login=True) as cr_instance:
            driver = cr_instance.driver
            self.open_files_application(driver)
            self.create_file(os.path.join(os.path.join(USER_LOCATION,
                                                       source), file_name))
            self.copy_file(driver, source, GOOGLE_DRIVE, file_name)
            errors = self.catch_info_or_error_messages(driver)
            if len(errors):
                raise error.TestFail("Test failed with the following"
                                     " errors. %s", errors)
        self.success = True
示例#8
0
import autotest
from autotest import autotest_lib
from autotest_lib.client.common_lib.cros import chromedriver
with chromedriver.chromedriver() as chromedriver_instance:
    driver = chromedriver_instance.driver

URL = "www.instagram.com"

driver.get(URL)