OLD | NEW |
| (Empty) |
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. | |
4 | |
5 from telemetry.page.actions import click_element | |
6 from telemetry.page.actions import wait | |
7 from telemetry.unittest import tab_test_case | |
8 | |
9 | |
10 class ClickElementActionTest(tab_test_case.TabTestCase): | |
11 def testClickWithSelectorWaitForNavigation(self): | |
12 self.Navigate('page_with_link.html') | |
13 self.assertEquals( | |
14 self._tab.EvaluateJavaScript('document.location.pathname;'), | |
15 '/page_with_link.html') | |
16 | |
17 data = {'selector': 'a[id="clickme"]'} | |
18 i = click_element.ClickElementAction(data) | |
19 data = {'condition': 'href_change'} | |
20 j = wait.WaitAction(data) | |
21 j.RunAction(None, self._tab, i) | |
22 | |
23 self.assertEquals( | |
24 self._tab.EvaluateJavaScript('document.location.pathname;'), | |
25 '/blank.html') | |
26 | |
27 def testClickWithSingleQuoteSelectorWaitForNavigation(self): | |
28 self.Navigate('page_with_link.html') | |
29 self.assertEquals( | |
30 self._tab.EvaluateJavaScript('document.location.pathname;'), | |
31 '/page_with_link.html') | |
32 | |
33 data = {'selector': 'a[id=\'clickme\']'} | |
34 i = click_element.ClickElementAction(data) | |
35 data = {'condition': 'href_change'} | |
36 j = wait.WaitAction(data) | |
37 j.RunAction(None, self._tab, i) | |
38 | |
39 self.assertEquals( | |
40 self._tab.EvaluateJavaScript('document.location.pathname;'), | |
41 '/blank.html') | |
42 | |
43 def testClickWithTextWaitForRefChange(self): | |
44 self.Navigate('page_with_link.html') | |
45 self.assertEquals( | |
46 self._tab.EvaluateJavaScript('document.location.pathname;'), | |
47 '/page_with_link.html') | |
48 | |
49 data = {'text': 'Click me'} | |
50 i = click_element.ClickElementAction(data) | |
51 data = {'condition': 'href_change'} | |
52 j = wait.WaitAction(data) | |
53 j.RunAction(None, self._tab, i) | |
54 | |
55 self.assertEquals( | |
56 self._tab.EvaluateJavaScript('document.location.pathname;'), | |
57 '/blank.html') | |
58 | |
59 def testClickWithXPathWaitForRefChange(self): | |
60 self.Navigate('page_with_link.html') | |
61 self.assertEquals( | |
62 self._tab.EvaluateJavaScript('document.location.pathname;'), | |
63 '/page_with_link.html') | |
64 | |
65 data = {'xpath': '//a[@id="clickme"]'} | |
66 i = click_element.ClickElementAction(data) | |
67 data = {'condition': 'href_change'} | |
68 j = wait.WaitAction(data) | |
69 j.RunAction(None, self._tab, i) | |
70 | |
71 self.assertEquals( | |
72 self._tab.EvaluateJavaScript('document.location.pathname;'), | |
73 '/blank.html') | |
OLD | NEW |