1# Copyright 2013 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4from telemetry.page.actions import page_action
5
6
7class NavigateAction(page_action.PageAction):
8  def __init__(self, attributes=None):
9    super(NavigateAction, self).__init__(attributes)
10    assert hasattr(self, 'url'), 'Must specify url for navigate action'
11
12  def RunAction(self, tab):
13    script_to_evaluate_on_commit = None
14    if hasattr(self, 'script_to_evaluate_on_commit'):
15      script_to_evaluate_on_commit = getattr(self,
16                                             'script_to_evaluate_on_commit')
17    if hasattr(self, 'timeout_seconds') and self.timeout_seconds:
18      tab.Navigate(self.url,
19                   script_to_evaluate_on_commit,
20                   self.timeout_seconds)
21    else:
22      tab.Navigate(self.url, script_to_evaluate_on_commit)
23    tab.WaitForDocumentReadyStateToBeInteractiveOrBetter()
24