Home | History | Annotate | Download | only in ap_configurators
      1 # Copyright (c) 2013 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 ap_spec
      6 import edimax_ap_configurator
      7 import os
      8 import time
      9 
     10 class Edimax6428nsAPConfigurator(
     11         edimax_ap_configurator.EdimaxAPConfigurator):
     12     """Derived class to control the Edimax-Br6428 AP."""
     13 
     14     def navigate_to_page(self, page_number):
     15         """Navigate to the required page.
     16 
     17         @param page_number: The page number to navigate to.
     18 
     19         """
     20         if page_number == 1:
     21             # Open the general settings page.
     22             page_url = os.path.join(self.admin_interface_url ,'wlbasic.asp')
     23             self.get_url(page_url)
     24             self.wait_for_object_by_xpath('//select[@name="band"]')
     25         elif page_number == 2:
     26             # Open the security settings page.
     27             page_url = os.path.join(self.admin_interface_url ,'wlencrypt.asp')
     28             self.get_url(page_url)
     29             self.wait_for_object_by_xpath('//select[@name="method"]')
     30         else:
     31             raise RuntimeError('Invalid page number passed.  Number of pages is'
     32                                '%d, page value sent was %d' %
     33                                (self.get_number_of_pages(), page_number))
     34 
     35 
     36     def save_page(self, page_number):
     37         """ Save page after applying settings.
     38 
     39         @param page_number: The page number to be saved.
     40 
     41         """
     42         xpath_ok = ('//input[@name="okbutton"]')
     43         self.click_button_by_xpath('//input[@src="graphics/apply1.gif"]',
     44                                     alert_handler=self._alert_handler)
     45         self.driver.find_element_by_xpath('//input[@value="APPLY"]').click()
     46         element = self.wait_for_object_by_xpath(xpath_ok)
     47         xpath_done = '//input[@name="okbutton" and @value="OK"]'
     48         while element and not(self.object_by_xpath_exist(xpath_done)):
     49             time.sleep(0.5)
     50         self.click_button_by_xpath(xpath_ok, alert_handler=self._alert_handler)
     51 
     52 
     53     def _set_security_wpapsk(self, security, shared_key, update_interval=None):
     54         self.wait_for_object_by_xpath('//input[@name="pskValue"]')
     55         self.select_item_from_popup_by_xpath('WPA pre-shared key',
     56                                              '//select[@name="method"]')
     57         if security == ap_spec.SECURITY_TYPE_WPAPSK:
     58             wpa_item = 'wpaCipher1'
     59         else:
     60             wpa_item = 'wpaCipher2'
     61         self.click_button_by_id(wpa_item, alert_handler=self._alert_handler)
     62         self.select_item_from_popup_by_xpath('Passphrase',
     63                                              '//select[@name="pskFormat"]')
     64         self.set_content_of_text_field_by_xpath(shared_key,
     65                                                 '//input[@name="pskValue"]',
     66                                                 abort_check=True)
     67 
     68 
     69     def _set_security_wep(self, key_value, authentication):
     70         self.wait_for_object_by_xpath('//input[@name="key1"]')
     71         self.select_item_from_popup_by_xpath('WEP', '//select[@name="method"]')
     72         self.select_item_from_popup_by_xpath('64-bit',
     73                                              '//select[@name="length"]')
     74         self.select_item_from_popup_by_xpath('ASCII (5  characters)',
     75                                              '//select[@name="format"]')
     76         self.set_content_of_text_field_by_xpath(key_value,
     77                                                 '//input[@name="key1"]',
     78                                                 abort_check=True)
     79