Home | History | Annotate | Download | only in actions
      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 
      5 from telemetry.internal.actions import page_action
      6 
      7 
      8 class WaitForElementAction(page_action.PageAction):
      9   def __init__(self, selector=None, text=None, element_function=None,
     10                timeout_in_seconds=60):
     11     super(WaitForElementAction, self).__init__()
     12     self.selector = selector
     13     self.text = text
     14     self.element_function = element_function
     15     self.timeout_in_seconds = timeout_in_seconds
     16 
     17   def RunAction(self, tab):
     18     code = 'function(element) { return element != null; }'
     19     page_action.EvaluateCallbackWithElement(
     20         tab, code, selector=self.selector, text=self.text,
     21         element_function=self.element_function,
     22         wait=True, timeout_in_seconds=self.timeout_in_seconds)
     23