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

Side by Side Diff: chrome/test/functional/extensions.py

Issue 9696018: Update pyauto tests to work with the uber page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: rebase Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/functional/chromeos_time.py ('k') | chrome/test/functional/history.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ 6 """
7 This module is a simple qa tool that installs extensions and tests whether the 7 This module is a simple qa tool that installs extensions and tests whether the
8 browser crashes while visiting a list of urls. 8 browser crashes while visiting a list of urls.
9 9
10 Usage: python extensions.py -v 10 Usage: python extensions.py -v
11 11
12 Note: This assumes that there is a directory of extensions called 12 Note: This assumes that there is a directory of extensions called
13 'extensions-tool' and that there is a file of newline-separated urls to visit 13 'extensions-tool' and that there is a file of newline-separated urls to visit
14 called 'urls.txt' in the data directory. 14 called 'urls.txt' in the data directory.
15 """ 15 """
16 16
17 import glob 17 import glob
18 import logging 18 import logging
19 import os 19 import os
20 import sys 20 import sys
21 21
22 import pyauto_functional # must be imported before pyauto 22 import pyauto_functional # must be imported before pyauto
23 import pyauto 23 import pyauto
24 24
25 25
26 class ExtensionsPage(object): 26 class ExtensionsPage(object):
27 """Access options in extensions page (chrome://settings/extensions).""" 27 """Access options in extensions page (chrome://extensions-frame)."""
28 28
29 _URL = 'chrome://settings/extensions' 29 _URL = 'chrome://extensions-frame'
30 30
31 def __init__(self, driver): 31 def __init__(self, driver):
32 self._driver = driver 32 self._driver = driver
33 self._driver.get(ExtensionsPage._URL) 33 self._driver.get(ExtensionsPage._URL)
34 34
35 def CheckExtensionVisible(self, ext_id): 35 def CheckExtensionVisible(self, ext_id):
36 """Returns True if |ext_id| Enabled checkbox exists on page.""" 36 """Returns True if |ext_id| exists on page."""
37 return len(self._driver.find_elements_by_id('toggle-%s' % ext_id)) == 1 37 return len(self._driver.find_elements_by_id(ext_id)) == 1
38 38
39 def SetEnabled(self, ext_id, enabled): 39 def SetEnabled(self, ext_id, enabled):
40 """Clicks on 'Enabled' checkbox for specified extension. 40 """Clicks on 'Enabled' checkbox for specified extension.
41 41
42 Args: 42 Args:
43 ext_id: Extension ID to be enabled or disabled. 43 ext_id: Extension ID to be enabled or disabled.
44 enabled: Boolean indicating whether |ext_id| is to be enabled or disabled. 44 enabled: Boolean indicating whether |ext_id| is to be enabled or disabled.
45 """ 45 """
46 checkbox = self._driver.find_element_by_id('toggle-%s' % ext_id) 46 checkbox = self._driver.find_element_by_xpath(
47 '//*[@id="%s"]//*[@class="enable-controls"]//*[@type="checkbox"]' %
48 ext_id)
47 if checkbox != enabled: 49 if checkbox != enabled:
48 checkbox.click() 50 checkbox.click()
49 # Reload page to ensure that the UI is recreated. 51 # Reload page to ensure that the UI is recreated.
50 self._driver.get(ExtensionsPage._URL) 52 self._driver.get(ExtensionsPage._URL)
51 53
52 def SetAllowInIncognito(self, ext_id, allowed): 54 def SetAllowInIncognito(self, ext_id, allowed):
53 """Clicks on 'Allow in incognito' checkbox for specified extension. 55 """Clicks on 'Allow in incognito' checkbox for specified extension.
54 56
55 Args: 57 Args:
56 ext_id: Extension ID to be enabled or disabled. 58 ext_id: Extension ID to be enabled or disabled.
57 allowed: Boolean indicating whether |ext_id| is to be allowed or 59 allowed: Boolean indicating whether |ext_id| is to be allowed or
58 disallowed in incognito. 60 disallowed in incognito.
59 """ 61 """
60 checkbox = self._driver.find_element_by_xpath( 62 checkbox = self._driver.find_element_by_xpath(
61 '//*[@id="%s"][@type="checkbox"]' % ext_id) 63 '//*[@id="%s"]//*[@class="incognito-control"]//*[@type="checkbox"]' %
62 # Expand extension and click on 'Allow in incognito'. 64 ext_id)
63 if not checkbox.is_displayed():
64 self._driver.find_element_by_id('%s_zippy' % ext_id).click()
65 if checkbox.is_selected() != allowed: 65 if checkbox.is_selected() != allowed:
66 checkbox.click() 66 checkbox.click()
67 # Reload page to ensure that the UI is recreated. 67 # Reload page to ensure that the UI is recreated.
68 self._driver.get(ExtensionsPage._URL) 68 self._driver.get(ExtensionsPage._URL)
69 69
70 def SetAllowAccessFileURLs(self, ext_id, allowed): 70 def SetAllowAccessFileURLs(self, ext_id, allowed):
71 """Clicks on 'Allow access to file URLs' checkbox for specified extension. 71 """Clicks on 'Allow access to file URLs' checkbox for specified extension.
72 72
73 Args: 73 Args:
74 ext_id: Extension ID to be enabled or disabled. 74 ext_id: Extension ID to be enabled or disabled.
75 allowed: Boolean indicating whether |ext_id| is to be allowed access to 75 allowed: Boolean indicating whether |ext_id| is to be allowed access to
76 file URLs. 76 file URLs.
77 """ 77 """
78 checkbox = self._driver.find_element_by_xpath( 78 checkbox = self._driver.find_element_by_xpath(
79 '(//*[@id="%s"][@type="checkbox"])[2]' % ext_id) 79 '//*[@id="%s"]//*[@class="file-access-control"]//*[@type="checkbox"]' %
80 # Expand extension and click on 'Allow access to file URLs'. 80 ext_id)
81 if not checkbox.is_displayed():
82 self._driver.find_element_by_id('%s_zippy' % ext_id).click()
83 if checkbox.is_selected() != allowed: 81 if checkbox.is_selected() != allowed:
84 checkbox.click() 82 checkbox.click()
85 83
86 84
87 class ExtensionsTest(pyauto.PyUITest): 85 class ExtensionsTest(pyauto.PyUITest):
88 """Test of extensions.""" 86 """Test of extensions."""
89 87
90 def Debug(self): 88 def Debug(self):
91 """Test method for experimentation. 89 """Test method for experimentation.
92 90
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 ext_page.SetAllowAccessFileURLs(ext_id, True) 458 ext_page.SetAllowAccessFileURLs(ext_id, True)
461 459
462 # Check that extension now has access to file URLs. 460 # Check that extension now has access to file URLs.
463 self.WaitUntil(self._FileAccess, args=[ext_id], expect_retval=True) 461 self.WaitUntil(self._FileAccess, args=[ext_id], expect_retval=True)
464 self.assertTrue(self._FileAccess(ext_id), 462 self.assertTrue(self._FileAccess(ext_id),
465 msg='Extension did not have access to file URLs granted.') 463 msg='Extension did not have access to file URLs granted.')
466 464
467 465
468 if __name__ == '__main__': 466 if __name__ == '__main__':
469 pyauto_functional.Main() 467 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/chromeos_time.py ('k') | chrome/test/functional/history.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698