1# Copyright 2012 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. 4 5from telemetry.page.actions import page_action 6 7class WaitForElementAction(page_action.PageAction): 8 def __init__(self, selector=None, text=None, element_function=None, 9 timeout=60): 10 super(WaitForElementAction, self).__init__() 11 self.selector = selector 12 self.text = text 13 self.element_function = element_function 14 self.timeout = timeout 15 16 def RunAction(self, tab): 17 code = 'function(element) { return element != null; }' 18 page_action.EvaluateCallbackWithElement( 19 tab, code, selector=self.selector, text=self.text, 20 element_function=self.element_function, 21 wait=True, timeout=self.timeout) 22