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
3 # found in the LICENSE file.
4 # pylint: disable=W0401,W0614
5 from telemetry.page.actions.all_page_actions import *
6 from telemetry.page import page as page_module
7 from telemetry.page import page_set as page_set_module
10 class GmailComposeDiscardPage(page_module.Page):
12 """ Why: Compose and discard a new email """
14 def __init__(self, page_set):
15 super(GmailComposeDiscardPage, self).__init__(
16 url='https://mail.google.com/mail/',
18 self.credentials_path = 'data/credentials.json'
19 self.credentials = 'google'
20 self.user_agent_type = 'desktop'
22 def RunNavigateSteps(self, action_runner):
23 action_runner.RunAction(NavigateAction())
24 action_runner.RunAction(WaitAction(
27 'window.gmonkey !== undefined &&'
28 'document.getElementById("gb") !== null')
31 def ComposeClick(self, action_runner):
32 action_runner.RunAction(JavascriptAction({
34 var button=document.evaluate('//div[text()="COMPOSE"]',
35 document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null)
37 var mousedownevent=new MouseEvent('mousedown',true,true,window,0,0,0,0,0,
38 false,false,false,false,0,null);
39 var mouseupevent=new MouseEvent('mouseup',true,true,window,0,0,0,0,0,
40 false,false,false,false,0,null);
41 button.dispatchEvent(mousedownevent);
42 button.dispatchEvent(mouseupevent);'''
45 def RunEndure(self, action_runner):
46 action_runner.RunAction(WaitAction(
48 'xpath': '//div[text()="COMPOSE"]',
49 'condition': 'element'
51 self.ComposeClick(action_runner)
52 action_runner.RunAction(WaitAction({"seconds": 1}))
53 action_runner.RunAction(WaitAction(
55 'condition': 'element',
56 'selector': 'div[class~="oh"][data-tooltip="Discard draft"]'
58 action_runner.RunAction(ClickElementAction(
60 'selector': 'div[class~="oh"][data-tooltip="Discard draft"]'
62 action_runner.RunAction(WaitAction({'seconds': 1}))
65 class GmailComposeDiscardPageSet(page_set_module.PageSet):
68 Description: Gmail endure test: compose and discard an email.
72 super(GmailComposeDiscardPageSet, self).__init__(
73 credentials_path='data/credentials.json',
74 user_agent_type='desktop',
75 archive_data_file='data/gmail_compose_discard.json')
77 self.AddPage(GmailComposeDiscardPage(self))