Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: tools/perf/page_sets/gmail_compose_discard.py

Issue 321563003: Add Wait* API to ActionRunner to wrap over WaitAction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing to head. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4
5 import re
6
4 # pylint: disable=W0401,W0614 7 # pylint: disable=W0401,W0614
5 from telemetry.page.actions.all_page_actions import * 8 from telemetry.page.actions.all_page_actions import *
6 from telemetry.page import page as page_module 9 from telemetry.page import page as page_module
7 from telemetry.page import page_set as page_set_module 10 from telemetry.page import page_set as page_set_module
8 11
9 12
13 def _CreateXpathFunction(xpath):
14 return ('document.evaluate(%s, document, null, '
15 'XPathResult.FIRST_ORDERED_NODE_TYPE, null)'
16 '.singleNodeEvaluate') % re.escape(xpath)
17
18
10 class GmailComposeDiscardPage(page_module.Page): 19 class GmailComposeDiscardPage(page_module.Page):
11 20
12 """ Why: Compose and discard a new email """ 21 """ Why: Compose and discard a new email """
13 22
14 def __init__(self, page_set): 23 def __init__(self, page_set):
15 super(GmailComposeDiscardPage, self).__init__( 24 super(GmailComposeDiscardPage, self).__init__(
16 url='https://mail.google.com/mail/', 25 url='https://mail.google.com/mail/',
17 page_set=page_set) 26 page_set=page_set)
18 self.credentials_path = 'data/credentials.json' 27 self.credentials_path = 'data/credentials.json'
19 self.credentials = 'google' 28 self.credentials = 'google'
20 self.user_agent_type = 'desktop' 29 self.user_agent_type = 'desktop'
21 30
22 def RunNavigateSteps(self, action_runner): 31 def RunNavigateSteps(self, action_runner):
23 action_runner.NavigateToPage(self) 32 action_runner.NavigateToPage(self)
24 action_runner.RunAction(WaitAction( 33 action_runner.WaitForJavaScriptCondition(
25 { 34 'window.gmonkey !== undefined &&'
26 'javascript': ( 35 'document.getElementById("gb") !== null')
27 'window.gmonkey !== undefined &&'
28 'document.getElementById("gb") !== null')
29 }))
30 36
31 def ComposeClick(self, action_runner): 37 def ComposeClick(self, action_runner):
32 action_runner.ExecuteJavaScript(''' 38 action_runner.ExecuteJavaScript('''
33 var button=document.evaluate('//div[text()="COMPOSE"]', 39 var button=document.evaluate('//div[text()="COMPOSE"]',
34 document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null) 40 document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null)
35 .singleNodeValue; 41 .singleNodeValue;
36 var mousedownevent=new MouseEvent('mousedown',true,true,window,0,0,0,0,0, 42 var mousedownevent=new MouseEvent('mousedown',true,true,window,0,0,0,0,0,
37 false,false,false,false,0,null); 43 false,false,false,false,0,null);
38 var mouseupevent=new MouseEvent('mouseup',true,true,window,0,0,0,0,0, 44 var mouseupevent=new MouseEvent('mouseup',true,true,window,0,0,0,0,0,
39 false,false,false,false,0,null); 45 false,false,false,false,0,null);
40 button.dispatchEvent(mousedownevent); 46 button.dispatchEvent(mousedownevent);
41 button.dispatchEvent(mouseupevent);''') 47 button.dispatchEvent(mouseupevent);''')
42 48
43 def RunEndure(self, action_runner): 49 def RunEndure(self, action_runner):
44 action_runner.RunAction(WaitAction( 50 action_runner.WaitForElement(
45 { 51 element_function=_CreateXpathFunction('//div[text()="COMPOSE"]'))
46 'xpath': '//div[text()="COMPOSE"]',
47 'condition': 'element'
48 }))
49 self.ComposeClick(action_runner) 52 self.ComposeClick(action_runner)
50 action_runner.RunAction(WaitAction({"seconds": 1})) 53 action_runner.Wait(1)
51 action_runner.RunAction(WaitAction( 54 action_runner.WaitForElement(
52 { 55 'div[class~="oh"][data-tooltip="Discard draft"]')
53 'condition': 'element',
54 'selector': 'div[class~="oh"][data-tooltip="Discard draft"]'
55 }))
56 action_runner.RunAction(ClickElementAction( 56 action_runner.RunAction(ClickElementAction(
57 { 57 {
58 'selector': 'div[class~="oh"][data-tooltip="Discard draft"]' 58 'selector': 'div[class~="oh"][data-tooltip="Discard draft"]'
59 })) 59 }))
60 action_runner.RunAction(WaitAction({'seconds': 1})) 60 action_runner.Wait(1)
61 61
62 62
63 class GmailComposeDiscardPageSet(page_set_module.PageSet): 63 class GmailComposeDiscardPageSet(page_set_module.PageSet):
64 64
65 """ 65 """
66 Description: Gmail endure test: compose and discard an email. 66 Description: Gmail endure test: compose and discard an email.
67 """ 67 """
68 68
69 def __init__(self): 69 def __init__(self):
70 super(GmailComposeDiscardPageSet, self).__init__( 70 super(GmailComposeDiscardPageSet, self).__init__(
71 credentials_path='data/credentials.json', 71 credentials_path='data/credentials.json',
72 user_agent_type='desktop') 72 user_agent_type='desktop')
73 73
74 self.AddPage(GmailComposeDiscardPage(self)) 74 self.AddPage(GmailComposeDiscardPage(self))
OLDNEW
« no previous file with comments | « tools/perf/page_sets/gmail_alt_two_labels.py ('k') | tools/perf/page_sets/gmail_expand_collapse_conversation.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698