Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / tools / telemetry / telemetry / page / actions / click_element_unittest.py
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.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
10
11
12 class ClickElementActionTest(tab_test_case.TabTestCase):
13   @test.Disabled('chromeos')
14   def testClickWithSelectorWaitForNavigation(self):
15     self._browser.SetHTTPServerDirectories(util.GetUnittestDataDir())
16     self._tab.Navigate(
17       self._browser.http_server.UrlOf('page_with_link.html'))
18     self._tab.WaitForDocumentReadyStateToBeComplete()
19     self.assertEquals(
20         self._tab.EvaluateJavaScript('document.location.pathname;'),
21         '/page_with_link.html')
22
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)
28
29     self.assertEquals(
30         self._tab.EvaluateJavaScript('document.location.pathname;'),
31         '/blank.html')
32
33   @test.Disabled('chromeos')
34   def testClickWithSingleQuoteSelectorWaitForNavigation(self):
35     self._browser.SetHTTPServerDirectories(util.GetUnittestDataDir())
36     self._tab.Navigate(
37       self._browser.http_server.UrlOf('page_with_link.html'))
38     self._tab.WaitForDocumentReadyStateToBeComplete()
39     self.assertEquals(
40         self._tab.EvaluateJavaScript('document.location.pathname;'),
41         '/page_with_link.html')
42
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)
48
49     self.assertEquals(
50         self._tab.EvaluateJavaScript('document.location.pathname;'),
51         '/blank.html')
52
53   @test.Disabled('chromeos')
54   def testClickWithTextWaitForRefChange(self):
55     self._browser.SetHTTPServerDirectories(util.GetUnittestDataDir())
56     self._tab.Navigate(
57       self._browser.http_server.UrlOf('page_with_link.html'))
58     self._tab.WaitForDocumentReadyStateToBeComplete()
59     self.assertEquals(
60         self._tab.EvaluateJavaScript('document.location.pathname;'),
61         '/page_with_link.html')
62
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)
68
69     self.assertEquals(
70         self._tab.EvaluateJavaScript('document.location.pathname;'),
71         '/blank.html')
72
73   @test.Disabled('chromeos')
74   def testClickWithXPathWaitForRefChange(self):
75     self._browser.SetHTTPServerDirectories(util.GetUnittestDataDir())
76     self._tab.Navigate(
77       self._browser.http_server.UrlOf('page_with_link.html'))
78     self._tab.WaitForDocumentReadyStateToBeComplete()
79     self.assertEquals(
80         self._tab.EvaluateJavaScript('document.location.pathname;'),
81         '/page_with_link.html')
82
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)
88
89     self.assertEquals(
90         self._tab.EvaluateJavaScript('document.location.pathname;'),
91         '/blank.html')