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.
7 from telemetry.page import page as page_module
8 from telemetry.page import page_set as page_set_module
11 def _CreateXpathFunction(xpath):
12 return ('document.evaluate("%s",'
15 'XPathResult.FIRST_ORDERED_NODE_TYPE,'
17 '.singleNodeValue' % re.escape(xpath))
20 def _GetCurrentLocation(action_runner):
21 return action_runner.EvaluateJavaScript('document.location.href')
24 def _WaitForLocationChange(action_runner, old_href):
25 action_runner.WaitForJavaScriptCondition(
26 'document.location.href != "%s"' % old_href)
29 class GmailAltThreadlistConversationPage(
32 """ Why: Alternate between Inbox and the first email conversation. """
34 def __init__(self, page_set):
35 super(GmailAltThreadlistConversationPage, self).__init__(
36 url='https://mail.google.com/mail/',
38 name='gmail_alt_threadlist_conversation')
39 self.credentials_path = 'data/credentials.json'
40 self.user_agent_type = 'desktop'
41 self.archive_data_file = 'data/gmail_alt_threadlist_conversation.json'
42 self.credentials = 'google'
44 def RunNavigateSteps(self, action_runner):
45 action_runner.NavigateToPage(self)
46 action_runner.WaitForJavaScriptCondition(
47 'window.gmonkey !== undefined && '
48 'document.getElementById("gb") !== null')
50 def RunEndure(self, action_runner):
51 old_href = _GetCurrentLocation(action_runner)
52 action_runner.ClickElement(
53 element_function=_CreateXpathFunction('//span[@email]'))
54 _WaitForLocationChange(action_runner, old_href)
56 old_href = _GetCurrentLocation(action_runner)
57 action_runner.ClickElement(
58 'a[href="https://mail.google.com/mail/u/0/?shva=1#inbox"]')
59 _WaitForLocationChange(action_runner, old_href)
63 class GmailAltThreadlistConversationPageSet(page_set_module.PageSet):
65 """ Chrome Endure test for GMail. """
68 super(GmailAltThreadlistConversationPageSet, self).__init__(
69 credentials_path='data/credentials.json',
70 user_agent_type='desktop',
71 archive_data_file='data/gmail_alt_threadlist_conversation.json',
72 bucket=page_set_module.PUBLIC_BUCKET)
74 self.AddPage(GmailAltThreadlistConversationPage(self))