1 # Copyright (c) 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.
5 from telemetry.core import util
6 from telemetry.page.actions import click_element
7 from telemetry.page.actions import wait
8 from telemetry.unittest import tab_test_case
9 from telemetry.unittest import test
12 class ClickElementActionTest(tab_test_case.TabTestCase):
13 @test.Disabled('chromeos')
14 def testClickWithSelectorWaitForNavigation(self):
15 self._browser.SetHTTPServerDirectories(util.GetUnittestDataDir())
17 self._browser.http_server.UrlOf('page_with_link.html'))
18 self._tab.WaitForDocumentReadyStateToBeComplete()
20 self._tab.EvaluateJavaScript('document.location.pathname;'),
21 '/page_with_link.html')
23 data = {'selector': 'a[id="clickme"]'}
24 i = click_element.ClickElementAction(data)
25 data = {'condition': 'href_change'}
26 j = wait.WaitAction(data)
27 j.RunAction(None, self._tab, i)
30 self._tab.EvaluateJavaScript('document.location.pathname;'),
33 @test.Disabled('chromeos')
34 def testClickWithSingleQuoteSelectorWaitForNavigation(self):
35 self._browser.SetHTTPServerDirectories(util.GetUnittestDataDir())
37 self._browser.http_server.UrlOf('page_with_link.html'))
38 self._tab.WaitForDocumentReadyStateToBeComplete()
40 self._tab.EvaluateJavaScript('document.location.pathname;'),
41 '/page_with_link.html')
43 data = {'selector': 'a[id=\'clickme\']'}
44 i = click_element.ClickElementAction(data)
45 data = {'condition': 'href_change'}
46 j = wait.WaitAction(data)
47 j.RunAction(None, self._tab, i)
50 self._tab.EvaluateJavaScript('document.location.pathname;'),
53 @test.Disabled('chromeos')
54 def testClickWithTextWaitForRefChange(self):
55 self._browser.SetHTTPServerDirectories(util.GetUnittestDataDir())
57 self._browser.http_server.UrlOf('page_with_link.html'))
58 self._tab.WaitForDocumentReadyStateToBeComplete()
60 self._tab.EvaluateJavaScript('document.location.pathname;'),
61 '/page_with_link.html')
63 data = {'text': 'Click me'}
64 i = click_element.ClickElementAction(data)
65 data = {'condition': 'href_change'}
66 j = wait.WaitAction(data)
67 j.RunAction(None, self._tab, i)
70 self._tab.EvaluateJavaScript('document.location.pathname;'),
73 @test.Disabled('chromeos')
74 def testClickWithXPathWaitForRefChange(self):
75 self._browser.SetHTTPServerDirectories(util.GetUnittestDataDir())
77 self._browser.http_server.UrlOf('page_with_link.html'))
78 self._tab.WaitForDocumentReadyStateToBeComplete()
80 self._tab.EvaluateJavaScript('document.location.pathname;'),
81 '/page_with_link.html')
83 data = {'xpath': '//a[@id="clickme"]'}
84 i = click_element.ClickElementAction(data)
85 data = {'condition': 'href_change'}
86 j = wait.WaitAction(data)
87 j.RunAction(None, self._tab, i)
90 self._tab.EvaluateJavaScript('document.location.pathname;'),