OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 import os | 4 import os |
5 | 5 |
6 from telemetry import click_element_action | 6 from telemetry.page import click_element_action |
7 from telemetry import tab_test_case | 7 from telemetry.test import tab_test_case |
8 | 8 |
9 class ClickElementActionTest(tab_test_case.TabTestCase): | 9 class ClickElementActionTest(tab_test_case.TabTestCase): |
10 def testClickWithSelectorWaitForNavigation(self): | 10 def testClickWithSelectorWaitForNavigation(self): |
11 unittest_data_dir = os.path.join(os.path.dirname(__file__), | 11 unittest_data_dir = os.path.join(os.path.dirname(__file__), |
12 '..', 'unittest_data') | 12 '..', '..', 'unittest_data') |
13 self._browser.SetHTTPServerDirectory(unittest_data_dir) | 13 self._browser.SetHTTPServerDirectory(unittest_data_dir) |
14 self._tab.Navigate( | 14 self._tab.Navigate( |
15 self._browser.http_server.UrlOf('page_with_link.html')) | 15 self._browser.http_server.UrlOf('page_with_link.html')) |
16 self._tab.WaitForDocumentReadyStateToBeComplete() | 16 self._tab.WaitForDocumentReadyStateToBeComplete() |
17 self.assertEquals( | 17 self.assertEquals( |
18 self._tab.EvaluateJavaScript('document.location.pathname;'), | 18 self._tab.EvaluateJavaScript('document.location.pathname;'), |
19 '/page_with_link.html') | 19 '/page_with_link.html') |
20 | 20 |
21 data = {'selector': 'a[id="clickme"]', 'wait_for_navigation': True} | 21 data = {'selector': 'a[id="clickme"]', 'wait_for_navigation': True} |
22 i = click_element_action.ClickElementAction(data) | 22 i = click_element_action.ClickElementAction(data) |
23 i.RunAction(None, self._tab, None) | 23 i.RunAction(None, self._tab, None) |
24 | 24 |
25 self.assertEquals( | 25 self.assertEquals( |
26 self._tab.EvaluateJavaScript('document.location.pathname;'), | 26 self._tab.EvaluateJavaScript('document.location.pathname;'), |
27 '/blank.html') | 27 '/blank.html') |
28 | 28 |
29 def testClickWithTextWaitForRefChange(self): | 29 def testClickWithTextWaitForRefChange(self): |
30 unittest_data_dir = os.path.join(os.path.dirname(__file__), | 30 unittest_data_dir = os.path.join(os.path.dirname(__file__), |
31 '..', 'unittest_data') | 31 '..', '..', 'unittest_data') |
32 self._browser.SetHTTPServerDirectory(unittest_data_dir) | 32 self._browser.SetHTTPServerDirectory(unittest_data_dir) |
33 self._tab.Navigate( | 33 self._tab.Navigate( |
34 self._browser.http_server.UrlOf('page_with_link.html')) | 34 self._browser.http_server.UrlOf('page_with_link.html')) |
35 self._tab.WaitForDocumentReadyStateToBeComplete() | 35 self._tab.WaitForDocumentReadyStateToBeComplete() |
36 self.assertEquals( | 36 self.assertEquals( |
37 self._tab.EvaluateJavaScript('document.location.pathname;'), | 37 self._tab.EvaluateJavaScript('document.location.pathname;'), |
38 '/page_with_link.html') | 38 '/page_with_link.html') |
39 | 39 |
40 data = {'text': 'Click me', 'wait_for_href_change': True} | 40 data = {'text': 'Click me', 'wait_for_href_change': True} |
41 i = click_element_action.ClickElementAction(data) | 41 i = click_element_action.ClickElementAction(data) |
42 i.RunAction(None, self._tab, None) | 42 i.RunAction(None, self._tab, None) |
43 | 43 |
44 self.assertEquals( | 44 self.assertEquals( |
45 self._tab.EvaluateJavaScript('document.location.pathname;'), | 45 self._tab.EvaluateJavaScript('document.location.pathname;'), |
46 '/blank.html') | 46 '/blank.html') |
OLD | NEW |