| Index: tools/perf/page_sets/gmail_compose_discard.py
|
| diff --git a/tools/perf/page_sets/gmail_compose_discard.py b/tools/perf/page_sets/gmail_compose_discard.py
|
| index 264878ba90b73baaca375f336e19b9f0bf8d7a3b..018dd9eec9968b4e989a574b3d14fe7a3aeaff2e 100644
|
| --- a/tools/perf/page_sets/gmail_compose_discard.py
|
| +++ b/tools/perf/page_sets/gmail_compose_discard.py
|
| @@ -1,12 +1,21 @@
|
| # Copyright 2014 The Chromium Authors. All rights reserved.
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
| +
|
| +import re
|
| +
|
| # pylint: disable=W0401,W0614
|
| from telemetry.page.actions.all_page_actions import *
|
| from telemetry.page import page as page_module
|
| from telemetry.page import page_set as page_set_module
|
|
|
|
|
| +def _CreateXpathFunction(xpath):
|
| + return ('document.evaluate(%s, document, null, '
|
| + 'XPathResult.FIRST_ORDERED_NODE_TYPE, null)'
|
| + '.singleNodeEvaluate') % re.escape(xpath)
|
| +
|
| +
|
| class GmailComposeDiscardPage(page_module.Page):
|
|
|
| """ Why: Compose and discard a new email """
|
| @@ -21,12 +30,9 @@ class GmailComposeDiscardPage(page_module.Page):
|
|
|
| def RunNavigateSteps(self, action_runner):
|
| action_runner.NavigateToPage(self)
|
| - action_runner.RunAction(WaitAction(
|
| - {
|
| - 'javascript': (
|
| - 'window.gmonkey !== undefined &&'
|
| - 'document.getElementById("gb") !== null')
|
| - }))
|
| + action_runner.WaitForJavaScriptCondition(
|
| + 'window.gmonkey !== undefined &&'
|
| + 'document.getElementById("gb") !== null')
|
|
|
| def ComposeClick(self, action_runner):
|
| action_runner.ExecuteJavaScript('''
|
| @@ -41,23 +47,17 @@ class GmailComposeDiscardPage(page_module.Page):
|
| button.dispatchEvent(mouseupevent);''')
|
|
|
| def RunEndure(self, action_runner):
|
| - action_runner.RunAction(WaitAction(
|
| - {
|
| - 'xpath': '//div[text()="COMPOSE"]',
|
| - 'condition': 'element'
|
| - }))
|
| + action_runner.WaitForElement(
|
| + element_function=_CreateXpathFunction('//div[text()="COMPOSE"]'))
|
| self.ComposeClick(action_runner)
|
| - action_runner.RunAction(WaitAction({"seconds": 1}))
|
| - action_runner.RunAction(WaitAction(
|
| - {
|
| - 'condition': 'element',
|
| - 'selector': 'div[class~="oh"][data-tooltip="Discard draft"]'
|
| - }))
|
| + action_runner.Wait(1)
|
| + action_runner.WaitForElement(
|
| + 'div[class~="oh"][data-tooltip="Discard draft"]')
|
| action_runner.RunAction(ClickElementAction(
|
| {
|
| 'selector': 'div[class~="oh"][data-tooltip="Discard draft"]'
|
| }))
|
| - action_runner.RunAction(WaitAction({'seconds': 1}))
|
| + action_runner.Wait(1)
|
|
|
|
|
| class GmailComposeDiscardPageSet(page_set_module.PageSet):
|
|
|