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 import os | |
5 | |
6 from telemetry import click_element_action | |
7 from telemetry import tab_test_case | |
8 | |
9 class ClickElementActionTest(tab_test_case.TabTestCase): | |
10 def testClickWithSelectorWaitForNavigation(self): | |
11 unittest_data_dir = os.path.join(os.path.dirname(__file__), | |
12 '..', 'unittest_data') | |
13 self._browser.SetHTTPServerDirectory(unittest_data_dir) | |
14 self._tab.Navigate( | |
15 self._browser.http_server.UrlOf('page_with_link.html')) | |
16 self._tab.WaitForDocumentReadyStateToBeComplete() | |
17 self.assertEquals( | |
18 self._tab.EvaluateJavaScript('document.location.pathname;'), | |
19 '/page_with_link.html') | |
20 | |
21 data = {'selector': 'a[id="clickme"]', 'wait_for_navigation': True} | |
22 i = click_element_action.ClickElementAction(data) | |
23 i.RunAction(None, self._tab, None) | |
24 | |
25 self.assertEquals( | |
26 self._tab.EvaluateJavaScript('document.location.pathname;'), | |
27 '/blank.html') | |
28 | |
29 def testClickWithTextWaitForRefChange(self): | |
30 unittest_data_dir = os.path.join(os.path.dirname(__file__), | |
31 '..', 'unittest_data') | |
32 self._browser.SetHTTPServerDirectory(unittest_data_dir) | |
33 self._tab.Navigate( | |
34 self._browser.http_server.UrlOf('page_with_link.html')) | |
35 self._tab.WaitForDocumentReadyStateToBeComplete() | |
36 self.assertEquals( | |
37 self._tab.EvaluateJavaScript('document.location.pathname;'), | |
38 '/page_with_link.html') | |
39 | |
40 data = {'text': 'Click me', 'wait_for_href_change': True} | |
41 i = click_element_action.ClickElementAction(data) | |
42 i.RunAction(None, self._tab, None) | |
43 | |
44 self.assertEquals( | |
45 self._tab.EvaluateJavaScript('document.location.pathname;'), | |
46 '/blank.html') | |
OLD | NEW |