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

Side by Side Diff: chrome/test/functional/ap_lab/linksys_ap_configurator.py

Issue 222873002: Remove pyauto tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 8 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
OLDNEW
(Empty)
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 import logging
6 import os
7
8 import ap_configurator
9 import selenium.common.exceptions
10
11
12 class LinksysAPConfigurator(ap_configurator.APConfigurator):
13
14 def __init__(self, pyauto_instance, admin_interface_url):
15 super(LinksysAPConfigurator, self).__init__(pyauto_instance)
16 # Override constants
17 self.security_disabled = 'Disabled'
18 self.security_wep = 'WEP'
19 self.security_wpapsk = 'WPA Personal'
20 self.security_wpa2psk = 'WPA2 Personal'
21 self.security_wpa8021x = 'WPA Enterprise'
22 self.security_wpa28021x = 'WPA2 Enterprise'
23
24 self.admin_interface_url = admin_interface_url
25
26 def GetRouterName(self):
27 return 'Router Name: WRT54G2; Class: LinksysAPConfigurator'
28
29 def GetRouterShortName(self):
30 return 'WRT54G2'
31
32 def GetNumberOfPages(self):
33 return 2
34
35 def GetSupportedBands(self):
36 return [{'band': self.k2GHz,
37 'channels': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]}]
38
39 def GetSupportedModes(self):
40 return [{'band': self.band_2ghz,
41 'modes': [self.mode_b, self.mode_g, self.mode_b | self.mode_g]}]
42
43 def NavigateToPage(self, page_number):
44 if page_number == 1:
45 self.pyauto_instance.NavigateToURL('http://%s/wireless.htm'
46 % self.admin_interface_url)
47 elif page_number == 2:
48 self.pyauto_instance.NavigateToURL('http://%s/WSecurity.htm'
49 % self.admin_interface_url)
50 else:
51 logging.exception('Invalid page number passed. Number of pages %d, '
52 'page value sent was %d', self.GetNumberOfPages(),
53 page_number)
54 return False
55 return True
56
57 def SavePage(self, page_number):
58 try:
59 self._wait.until(lambda _:
60 self._driver.find_element_by_xpath('id("divBT1")'))
61 except selenium.common.exceptions.TimeoutException, e:
62 logging.exception('Unable to locate the save button.\nWebDriver'
63 ' exception: %s', str(e))
64 return False
65 button = self._driver.find_element_by_xpath('id("divBT1")')
66 button.click()
67 # Wait for the continue button
68 continue_xpath = '//input[@value="Continue" and @type="button"]'
69 try:
70 self._wait.until(lambda _:
71 self._driver.find_element_by_xpath(continue_xpath))
72 except selenium.common.exceptions.TimeoutException, e:
73 logging.exception('Unable to location the continue button, save probably'
74 ' failed.\nWebDriver exception: %s', str(e))
75 return False
76 button = self._driver.find_element_by_xpath(continue_xpath)
77 button.click()
78 return True
79
80 def SetMode(self, mode, band=None):
81 self.AddItemToCommandList(self._SetMode, (mode,), 1, 900)
82
83 def _SetMode(self, mode):
84 # Different bands are not supported so we ignore.
85 # Create the mode to popup item mapping
86 mode_mapping = {self.mode_b: 'B-Only', self.mode_g: 'G-Only',
87 self.mode_b | self.mode_g: 'Mixed'}
88 mode_name = ''
89 if mode in mode_mapping.keys():
90 mode_name = mode_mapping[mode]
91 else:
92 logging.exception('The mode selected %d is not supported by router %s.',
93 hex(mode), self.getRouterName())
94 xpath = ('//select[@onchange="SelWL()" and @name="Mode"]')
95 self.SelectItemFromPopupByXPath(mode_name, xpath)
96
97 def SetRadio(self, enabled=True):
98 # If we are enabling we are activating all other UI components, do it
99 # first. Otherwise we are turning everything off so do it last.
100 if enabled:
101 weight = 1
102 else:
103 weight = 1000
104 self.AddItemToCommandList(self._SetRadio, (enabled,), 1, weight)
105
106 def _SetRadio(self, enabled=True):
107 xpath = ('//select[@onchange="SelWL()" and @name="Mode"]')
108 # To turn off we pick disabled, to turn on we set to G
109 if not enabled:
110 setting = 'Disabled'
111 else:
112 setting = 'G-Only'
113 self.SelectItemFromPopupByXPath(setting, xpath)
114
115 def SetSSID(self, ssid):
116 self.AddItemToCommandList(self._SetSSID, (ssid,), 1, 900)
117
118 def _SetSSID(self, ssid):
119 self._SetRadio(enabled=True)
120 xpath = ('//input[@maxlength="32" and @name="SSID"]')
121 self.SetConentsOfTextFieldByXPath(ssid, xpath)
122
123 def SetChannel(self, channel):
124 self.AddItemToCommandList(self._SetChannel, (channel,), 1, 900)
125
126 def _SetChannel(self, channel):
127 self._SetRadio(enabled=True)
128 channel_choices = ['1 - 2.412GHz', '2 - 2.417GHz', '3 - 2.422GHz',
129 '4 - 2.427GHz', '5 - 2.432GHz', '6 - 2.437GHz',
130 '7 - 2.442GHz', '8 - 2.447GHz', '9 - 2.452GHz',
131 '10 - 2.457GHz', '11 - 2.462GHz']
132 xpath = ('//select[@onfocus="check_action(this,0)" and @name="Freq"]')
133 self.SelectItemFromPopupByXPath(channel_choices[channel - 1], xpath)
134
135 def SetBand(self, band):
136 return None
137
138 def SetSecurityDisabled(self):
139 self.AddItemToCommandList(self._SetSecurityDisabled, (), 2, 1000)
140
141 def _SetSecurityDisabled(self):
142 xpath = ('//select[@name="SecurityMode"]')
143 self.SelectItemFromPopupByXPath(self.security_disabled, xpath)
144
145 def SetSecurityWEP(self, key_value, authentication):
146 self.AddItemToCommandList(self._SetSecurityWEP, (key_value, authentication),
147 2, 1000)
148
149 def _SetSecurityWEP(self, key_value, authentication):
150 logging.info('This router %s does not support WEP authentication type: %s',
151 self.GetRouterName(), authentication)
152 popup = '//select[@name="SecurityMode"]'
153 try:
154 self._wait.until(lambda _: self._driver.find_element_by_xpath(popup))
155 except selenium.common.exceptions.TimeoutException, e:
156 logging.exception('Unable to find the security mode pop up.\nWebDriver '
157 ' exception: %s', str(e))
158 text_field = ('//input[@name="wl_passphrase"]')
159 self.SelectItemFromPopupByXPath(self.security_wep, popup,
160 wait_for_xpath=text_field)
161 self.SetConentsOfTextFieldByXPath(key_value, text_field)
162 button = self._driver.find_element_by_xpath('//input[@value="Generate"]')
163 button.click()
164
165 def SetSecurityWPAPSK(self, shared_key, update_interval=1800):
166 self.AddItemToCommandList(self._SetSecurityWPAPSK,
167 (shared_key, update_interval), 1, 900)
168
169 def _SetSecurityWPAPSK(self, shared_key, update_interval=1800):
170 popup = '//select[@name="SecurityMode"]'
171 try:
172 self._wait.until(lambda _: self._driver.find_element_by_xpath(popup))
173 except selenium.common.exceptions.TimeoutException, e:
174 logging.exception('Unable to find the security mode pop up. WebDriver '
175 ' exception: %s', str(e))
176 key_field = '//input[@name="PassPhrase"]'
177 self.SelectItemFromPopupByXPath(self.security_wpapsk, popup,
178 wait_for_xpath=key_field)
179 self.SetConentsOfTextFieldByXPath(shared_key, key_field)
180 interval_field = ('//input[@name="GkuInterval"]')
181 self.SetConentsOfTextFieldByXPath(str(update_interval), interval_field)
182
183 def SetVisibility(self, visible=True):
184 self.AddItemToCommandList(self._SetVisibility, (visible,), 1, 900)
185
186 def _SetVisibility(self, visible=True):
187 self._SetRadio(enabled=True)
188 # value=1 is visible; value=0 is invisible
189 int_value = 1
190 if not visible:
191 int_value = 0
192 xpath = ('//input[@value="%d" and @name="wl_closed"]' % int_value)
193 element = self._driver.find_element_by_xpath(xpath)
194 element.click()
195
OLDNEW
« no previous file with comments | « chrome/test/functional/ap_lab/dlink_ap_configurator.py ('k') | chrome/test/functional/ap_lab/pyauto_ap_configurator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698