Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: telemetry/examples/browser_tests/simple_browser_test.py

Issue 2692763002: Revert of [Telemetry] Switch clients to new JavaScript API (batch 5) (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | telemetry/telemetry/core/local_server_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 import sys 5 import sys
6 import os 6 import os
7 7
8 from telemetry.testing import serially_executed_browser_test_case 8 from telemetry.testing import serially_executed_browser_test_case
9 9
10 10
(...skipping 15 matching lines...) Expand all
26 super(cls, SimpleBrowserTest).setUpClass() 26 super(cls, SimpleBrowserTest).setUpClass()
27 cls.SetBrowserOptions(cls._finder_options) 27 cls.SetBrowserOptions(cls._finder_options)
28 cls.StartBrowser() 28 cls.StartBrowser()
29 cls.action_runner = cls.browser.tabs[0].action_runner 29 cls.action_runner = cls.browser.tabs[0].action_runner
30 cls.SetStaticServerDirs( 30 cls.SetStaticServerDirs(
31 [os.path.join(os.path.abspath(__file__), '..', 'pages')]) 31 [os.path.join(os.path.abspath(__file__), '..', 'pages')])
32 32
33 def JavascriptTest(self, file_path, num_1, num_2, expected_sum): 33 def JavascriptTest(self, file_path, num_1, num_2, expected_sum):
34 url = self.UrlOfStaticFilePath(file_path) 34 url = self.UrlOfStaticFilePath(file_path)
35 self.action_runner.Navigate(url) 35 self.action_runner.Navigate(url)
36 actual_sum = self.action_runner.EvaluateJavaScript2( 36 # TODO(catapult:#3028): Fix interpolation of JavaScript values.
37 '{{ num_1 }} + {{ num_2 }}', num_1=num_1, num_2=num_2) 37 actual_sum = self.action_runner.EvaluateJavaScript(
38 '%i + %i' % (num_1, num_2))
38 self.assertEquals(expected_sum, actual_sum) 39 self.assertEquals(expected_sum, actual_sum)
39 40
40 def TestClickablePage(self): 41 def TestClickablePage(self):
41 url = self.UrlOfStaticFilePath('page_with_clickables.html') 42 url = self.UrlOfStaticFilePath('page_with_clickables.html')
42 self.action_runner.Navigate(url) 43 self.action_runner.Navigate(url)
43 self.action_runner.ExecuteJavaScript2('valueSettableByTest = 1997') 44 self.action_runner.ExecuteJavaScript('valueSettableByTest = 1997')
44 self.action_runner.ClickElement(text='Click/tap me') 45 self.action_runner.ClickElement(text='Click/tap me')
45 self.assertEqual( 46 self.assertEqual(1997, self.action_runner.EvaluateJavaScript('valueToTest'))
46 1997, self.action_runner.EvaluateJavaScript2('valueToTest'))
47 47
48 def TestAndroidUI(self): 48 def TestAndroidUI(self):
49 if self.platform.GetOSName() != 'android': 49 if self.platform.GetOSName() != 'android':
50 self.skipTest('The test is for android only') 50 self.skipTest('The test is for android only')
51 url = self.UrlOfStaticFilePath('page_with_clickables.html') 51 url = self.UrlOfStaticFilePath('page_with_clickables.html')
52 # Nativgate to page_with_clickables.html 52 # Nativgate to page_with_clickables.html
53 self.action_runner.Navigate(url) 53 self.action_runner.Navigate(url)
54 # Click on history 54 # Click on history
55 self.platform.system_ui.WaitForUiNode( 55 self.platform.system_ui.WaitForUiNode(
56 resource_id='com.google.android.apps.chrome:id/menu_button') 56 resource_id='com.google.android.apps.chrome:id/menu_button')
57 self.platform.system_ui.GetUiNode( 57 self.platform.system_ui.GetUiNode(
58 resource_id='com.google.android.apps.chrome:id/menu_button').Tap() 58 resource_id='com.google.android.apps.chrome:id/menu_button').Tap()
59 self.platform.system_ui.WaitForUiNode(content_desc='History') 59 self.platform.system_ui.WaitForUiNode(content_desc='History')
60 self.platform.system_ui.GetUiNode(content_desc='History').Tap() 60 self.platform.system_ui.GetUiNode(content_desc='History').Tap()
61 # Click on the first entry of the history (page_with_clickables.html) 61 # Click on the first entry of the history (page_with_clickables.html)
62 self.action_runner.WaitForElement('#id-0') 62 self.action_runner.WaitForElement('#id-0')
63 self.action_runner.ClickElement('#id-0') 63 self.action_runner.ClickElement('#id-0')
64 # Verify that the page's js is interactable 64 # Verify that the page's js is interactable
65 self.action_runner.WaitForElement(text='Click/tap me') 65 self.action_runner.WaitForElement(text='Click/tap me')
66 self.action_runner.ExecuteJavaScript2('valueSettableByTest = 1997') 66 self.action_runner.ExecuteJavaScript('valueSettableByTest = 1997')
67 self.action_runner.ClickElement(text='Click/tap me') 67 self.action_runner.ClickElement(text='Click/tap me')
68 self.assertEqual( 68 self.assertEqual(1997, self.action_runner.EvaluateJavaScript('valueToTest'))
69 1997, self.action_runner.EvaluateJavaScript2('valueToTest'))
70 69
71 70
72 def load_tests(loader, tests, pattern): 71 def load_tests(loader, tests, pattern):
73 del loader, tests, pattern # Unused. 72 del loader, tests, pattern # Unused.
74 return serially_executed_browser_test_case.LoadAllTestsInModule( 73 return serially_executed_browser_test_case.LoadAllTestsInModule(
75 sys.modules[__name__]) 74 sys.modules[__name__])
OLDNEW
« no previous file with comments | « no previous file | telemetry/telemetry/core/local_server_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698