Esempio n. 1
0
    def __init__(self,
                 launcher_params,
                 url,
                 log_file=None,
                 target_params=None,
                 success_message=None,
                 log_handler=None):
        """CobaltRunner constructor.

    Args:
      launcher_params:  An object storing all platform configuration and device
        information parameters.
      url:              The initial URL to launch Cobalt on.
      log_file:         The log file's name string.
      target_params:    An array of command line arguments to launch Cobalt
        with.
      success_message:  Optional success message to be printed on successful
        exit.
    """

        self.test_script_started = threading.Event()
        self.launcher = None
        self.webdriver = None
        self.failed = False
        self.should_exit = threading.Event()
        self.launcher_is_running = False
        self.windowdriver_created = threading.Event()
        self.webmodule_loaded = threading.Event()

        self.selenium_webdriver_module = webdriver_utils.import_selenium_module(
            'webdriver')

        self.launcher_params = launcher_params
        self.log_handler = log_handler

        if log_file:
            self.log_file = open(log_file)
            logging.basicConfig(stream=self.log_file, level=logging.INFO)
        else:
            self.log_file = sys.stdout
        self.url = url
        self.target_params = target_params
        self.success_message = success_message
        url_string = '--url=' + self.url
        if not self.target_params:
            self.target_params = [url_string]
        else:
            self.target_params.append(url_string)
        if self.launcher_params.target_params:
            self.target_params.extend(self.launcher_params.target_params)
Esempio n. 2
0
    def __init__(self,
                 device_params,
                 url,
                 log_file=None,
                 target_params=None,
                 success_message=None):
        """CobaltRunner constructor.

    Args:
      device_params:    A DeviceParams object storing all device specific info.
      url:              The intial URL to launch Cobalt on.
      log_file:         The log file's name string.
      target_params:    An array of command line arguments to launch Cobalt
        with.
      success_message:  Optional success message to be printed on successful
        exit.
    """

        self.test_script_started = threading.Event()
        self.launcher = None
        self.webdriver = None
        self.failed = False
        self.should_exit = threading.Event()
        self.launcher_is_running = False
        self.windowdriver_created = threading.Event()
        self.webmodule_loaded = threading.Event()

        self.selenium_webdriver_module = webdriver_utils.import_selenium_module(
            'webdriver')

        self.platform = device_params.platform
        self.config = device_params.config
        self.device_id = device_params.device_id
        self.out_directory = device_params.out_directory
        if log_file:
            self.log_file = open(log_file)
        else:
            self.log_file = sys.stdout
        self.url = url
        self.target_params = target_params
        self.success_message = success_message
        url_string = '--url=' + self.url
        if not self.target_params:
            self.target_params = [url_string]
        else:
            self.target_params.append(url_string)
Esempio n. 3
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""A module to support fundamental communications with Cobalt application."""

import json
import logging
import threading
import time

import _env  # pylint: disable=unused-import
from cobalt.tools.automated_testing import cobalt_runner
from cobalt.tools.automated_testing import webdriver_utils

webdriver_keys = webdriver_utils.import_selenium_module('webdriver.common.keys')

PERIODIC_QUERIES_INTERVAL_SECONDS = 0.1
THREAD_EXIT_TIMEOUT_SECONDS = 10
WAIT_INTERVAL_SECONDS = 0.5
WAIT_UNTIL_REACH_STATE_DEFAULT_TIMEOUT_SECONDS = 30
WAIT_UNTIL_ADS_END_DEFAULT_TIMEOUT_SECONDS = 120
WAIT_UNTIL_MEDIA_TIME_REACHED_DEFAULT_TIMEOUT_SECONDS = 30

ACCOUNT_SELECTOR_ADD_ACCOUNT_TEXT = u'Add account'


def GetValueFromQueryResult(query_result, key, default):
  if query_result is None:
    return default
Esempio n. 4
0
# Pattern to match Cobalt log line for when the WebDriver port has been
# opened.
RE_WEBDRIVER_LISTEN = re.compile(r'Starting WebDriver server on port (\d+)')
# Pattern to match Cobalt log line if WebDriver server fails to start.
RE_WEBDRIVER_FAILED = re.compile(r'Could not start WebDriver server')
# Pattern to match Cobalt log line for when a WindowDriver has been created.
RE_WINDOWDRIVER_CREATED = re.compile((
    r'^\[[\d:]+/[\d.]+:INFO:browser_module\.cc\(\d+\)\] Created WindowDriver: '
    r'ID=\S+'))
# Pattern to match Cobalt log line for when a WebModule is has been loaded.
RE_WEBMODULE_LOADED = re.compile(
    r'^\[[\d:]+/[\d.]+:INFO:browser_module\.cc\(\d+\)\] Loaded WebModule')

# selenium imports
# pylint: disable=C0103
ActionChains = webdriver_utils.import_selenium_module(
    submodule='webdriver.common.action_chains').ActionChains
keys = webdriver_utils.import_selenium_module('webdriver.common.keys')
selenium_exceptions = webdriver_utils.import_selenium_module(
    'common.exceptions')

DEFAULT_STARTUP_TIMEOUT_SECONDS = 2 * 60
WEBDRIVER_HTTP_TIMEOUT_SECONDS = 2 * 60
COBALT_EXIT_TIMEOUT_SECONDS = 5
PAGE_LOAD_WAIT_SECONDS = 30
WINDOWDRIVER_CREATED_TIMEOUT_SECONDS = 45
WEBMODULE_LOADED_TIMEOUT_SECONDS = 45
FIND_ELEMENT_RETRY_LIMIT = 20
EXECUTE_JAVASCRIPT_RETRY_LIMIT = 10

COBALT_WEBDRIVER_CAPABILITIES = {
    'browserName': 'cobalt',