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