def cleanup(self): columns = utils.get_var_details() #Steps to delete a var created from var collection var_name = columns['var_business_name'][0] var_name = var_name.strip() db.delete_var(var_name) #Steps to delete var user created from user collection var_email = columns['email'][0] var_email = var_email.strip() db.delete_user(var_email) #Steps to delete a customer created from customer collection cust_name = columns['var_business_name'][1] cust_name = cust_name.strip() db.delete_customer(cust_name) #Steps to delete customer user created from user collection cust_email = columns['email'][1] cust_email = cust_email.strip() db.delete_user(cust_email) #Steps to delete a config created config_name = columns['var_business_name'][2] config_name = config_name.strip() db.delete_config(config_name) #Steps to delete a location created loc_name = columns['var_business_name'][2] loc_name = loc_name.strip() db.delete_location(loc_name)
def reset_original_config_to_ap(self): self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url = properties.vm_url columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][1]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][1]) driver.find_element_by_id("btnLogin").click() time.sleep(10) driver.find_element_by_id("menuConfigurations").click() time.sleep(10) i = 0 for option in driver.find_elements_by_css_selector("#config_grid_table tbody tr"): template_name_id = "Template_Name_" + str(i) edit_button_id = "Edit_" + str(i) template_name = driver.find_element_by_id(template_name_id).get_attribute('innerHTML') if template_name == columns['var_business_name'][2]: driver.find_element_by_css_selector("#" + edit_button_id + " img").click() #driver.find_element_by_id("btnAddTemplate").click() time.sleep(5) driver.find_element_by_id("config_name").clear() driver.find_element_by_id("config_name").send_keys(columns['var_business_name'][2]) driver.find_element_by_id("radio_header").click() Select(driver.find_element_by_name("radio_50g_status")).select_by_visible_text("On") driver.find_element_by_id("network_header").click() driver.find_element_by_id("ssid_1").clear() driver.find_element_by_id("submitButton").click() driver.quit()
def setUpClass(self): global driver, columns self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url = properties.vm_url self.accept_next_alert = True driver = self.driver columns = utils.get_var_details()
def setUpClass(self): #display = Display(visible=0, size =(800,600)) #display.start() global driver, columns self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url = properties.vm_url self.accept_next_alert = True driver = self.driver columns = utils.get_var_details()
def create_location(self): columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns["email"][0]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns["password"][0]) driver.find_element_by_id("btnLogin").click() time.sleep(10) # print "Clickin Customers default dropdown" # dropdown = driver.find_element_by_id("customerFilter") # for option in dropdown.find_elements_by_tag_name("option"): # if option.get_attribute('value') == "-1": # option.click() # time.sleep(5) print "Clicking VAR filter dropdown" dropdown = driver.find_element_by_id("varFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns["var_business_name"][0]: option.click() time.sleep(5) print "Clickin Customers dropdown" dropdown = driver.find_element_by_id("customerFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns["var_business_name"][1]: option.click() time.sleep(5) driver.find_element_by_id("btnAddLocation").click() driver.find_element_by_id("name").clear() driver.find_element_by_id("name").send_keys(columns["var_business_name"][2]) driver.find_element_by_id("street_addr_line_1").clear() driver.find_element_by_id("street_addr_line_1").send_keys(columns["street_addres_1"][2]) driver.find_element_by_id("street_addr_line_2").clear() driver.find_element_by_id("street_addr_line_2").send_keys(columns["street_addres_2"][2]) driver.find_element_by_id("city").clear() driver.find_element_by_id("city").send_keys(columns["city"][2]) driver.find_element_by_id("state").clear() driver.find_element_by_id("state").send_keys(columns["state"][2]) driver.find_element_by_id("zip_code").clear() driver.find_element_by_id("zip_code").send_keys(columns["zip"][2]) config_dropdown = driver.find_element_by_id("config_id") for option in config_dropdown.find_elements_by_tag_name("option"): if option.text == columns["var_business_name"][2]: option.click() time.sleep(5) driver.find_element_by_id("btnAddLocation").click() time.sleep(3) db.search_location_in_location_collection(columns["var_business_name"][2])
def create_customer(self): columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][0]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][0]) driver.find_element_by_id("btnLogin").click() #driver.get(self.base_url + "/var/var_dashboard") time.sleep(10) print "Clicking VAR filter dropdown" dropdown = driver.find_element_by_id("varFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][0]: option.click() time.sleep(5) driver.find_element_by_id("btnAddCustomer").click() driver.find_element_by_id("name").clear() driver.find_element_by_id("name").send_keys(columns['var_business_name'][1]) driver.find_element_by_id("street_addr_line_1").clear() driver.find_element_by_id("street_addr_line_1").send_keys(columns['street_addres_1'][1]) driver.find_element_by_id("street_addr_line_2").clear() driver.find_element_by_id("street_addr_line_2").send_keys(columns['street_addres_2'][1]) driver.find_element_by_id("city").clear() driver.find_element_by_id("city").send_keys(columns['city'][1]) driver.find_element_by_id("zip_code").clear() driver.find_element_by_id("zip_code").send_keys(columns['zip'][1]) driver.find_element_by_id("first_name").clear() driver.find_element_by_id("first_name").send_keys(columns['first_name'][1]) driver.find_element_by_id("last_name").clear() driver.find_element_by_id("last_name").send_keys(columns['last_name'][1]) driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][1]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][1]) driver.find_element_by_id("confirm_password").clear() driver.find_element_by_id("confirm_password").send_keys(columns['confirm_password'][1]) driver.find_element_by_id("btnAddCustomer").click() #Verify Customer user was created in database cust_name = str(columns['var_business_name'][1]) print "Customer name is: " + cust_name time.sleep(2) db.search_cust_in_customer_collection(cust_name)
def create_config(self): columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][0]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][0]) driver.find_element_by_id("btnLogin").click() time.sleep(10) print "Clicking VAR filter dropdown" dropdown = driver.find_element_by_id("varFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][0]: option.click() time.sleep(5) print "Clickin Customers dropdown" dropdown = driver.find_element_by_id("customerFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][1]: option.click() time.sleep(5) driver.find_element_by_id("menuConfigurations").click() driver.find_element_by_id("btnAddTemplate").click() time.sleep(5) driver.find_element_by_id("config_name").clear() driver.find_element_by_id("config_name").send_keys(columns['var_business_name'][2]) driver.find_element_by_id("network_header").click() driver.find_element_by_id("ssid_0").clear() driver.find_element_by_id("ssid_0").send_keys(columns['var_business_name'][2]) time.sleep(5) print "Clicking passphrase type dropdwon" passphrase_dropdown = driver.find_element_by_id("security_0") for option in passphrase_dropdown.find_elements_by_tag_name("option"): if option.get_attribute('value') == "wpa-psk": option.click() time.sleep(5) driver.find_element_by_id("passphrase_0").clear() driver.find_element_by_id("passphrase_0").send_keys("accelera") driver.find_element_by_id("submitButton").click() time.sleep(3) db.search_config_in_configuration_collection(columns['var_business_name'][2])
def onboard_ap(self): columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][0]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][0]) driver.find_element_by_id("btnLogin").click() time.sleep(10) print "Clicking VAR filter dropdown" dropdown = driver.find_element_by_id("varFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][0]: option.click() time.sleep(5) print "Clickin Customers dropdown" dropdown = driver.find_element_by_id("customerFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][1]: option.click() time.sleep(5) print "Clickin Location dropdown" dropdown = driver.find_element_by_id("locationFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][2]: option.click() time.sleep(5) driver.find_element_by_id("menuAccessPoints").click() driver.find_element_by_id("addBtn").click() driver.find_element_by_id("ap_name").clear() driver.find_element_by_id("ap_name").send_keys(properties.ap_name) driver.find_element_by_id("serial_number").clear() ap_jid = utils.get_ap_jid(properties.real_ap_ip) serial_no = db.search_serialno_in_new_ap_collection(ap_jid.strip()) driver.find_element_by_id("serial_number").send_keys(serial_no) driver.find_element_by_id("addBtn").click() #driver.find_element_by_id("cancelBtn").click() time.sleep(3) db.search_ap_in_ap_collection(ap_jid.strip())
def create_var(self): columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") time.sleep(5) driver.find_element_by_id("SignUpLink").click() time.sleep(5) driver.find_element_by_id("name").clear() driver.find_element_by_id("name").send_keys(columns['var_business_name'][0]) driver.find_element_by_id("street_addr_line_1").clear() driver.find_element_by_id("street_addr_line_1").send_keys(columns['street_addres_1'][0]) driver.find_element_by_id("street_addr_line_2").clear() driver.find_element_by_id("street_addr_line_2").send_keys(columns['street_addres_2'][0]) driver.find_element_by_id("city").clear() driver.find_element_by_id("city").send_keys(columns['city'][0]) driver.find_element_by_id("zip_code").clear() driver.find_element_by_id("zip_code").send_keys(columns['zip'][0]) driver.find_element_by_id("first_name").clear() driver.find_element_by_id("first_name").send_keys(columns['first_name'][0]) driver.find_element_by_id("last_name").clear() driver.find_element_by_id("last_name").send_keys(columns['last_name'][0]) driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][0]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][0]) driver.find_element_by_id("confirm_password").clear() driver.find_element_by_id("confirm_password").send_keys(columns['confirm_password'][0]) driver.find_element_by_id("btnSignUp").click() time.sleep(10) #Verify VAR user was created in database var_name = str(columns['var_business_name'][0]) db.search_var_in_var_collection(var_name) self.assertTrue(driver.find_element_by_id("congrats-popup").is_displayed()) driver.find_element_by_id("LoginLink").click()
def _1_apply_config(self): """This test case verifies whether config is applied to AP successfully. """ columns = utils.get_var_details() driver = self.driver config_name = self.config_name driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns["email"][1]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns["password"][1]) driver.find_element_by_id("btnLogin").click() time.sleep(10) driver.find_element_by_id("menuAccessPoints").click() time.sleep(5) i = 0 for option in driver.find_elements_by_css_selector("#ap_grid_table tbody tr"): client_name_id = "AP_Name_" + str(i) status_id = "Status_" + str(i) select_checkbox_id = "_" + str(i) if ( properties.ap_name == str(driver.find_element_by_css_selector("#" + client_name_id + " a").get_attribute("innerHTML")) and driver.find_element_by_css_selector("#" + status_id + " img").get_attribute("title") == "available" ): # print "pass" driver.find_element_by_css_selector("#" + select_checkbox_id + " div").click() time.sleep(5) driver.find_element_by_id("applyTemplateBtn").click() j = 0 for option1 in driver.find_elements_by_css_selector("#config_list_table tbody tr"): template_name_id = "Template_name_" + str(j) select_radiobutton_id = "__" + str(j) # print select_radiobutton_id if config_name == driver.find_element_by_id(template_name_id).get_attribute("innerHTML"): driver.find_element_by_css_selector("#" + select_radiobutton_id + " input").click() driver.find_element_by_xpath("//html/body/div[2]/div/div/div/div[2]/div[2]/a").click() # driver.find_element_by_id("btnApply").click() j = j + 1 time.sleep(5) ##Checking for API response message which comes up after applying config to AP. try: actual_message = driver.find_element_by_xpath('//*[@id="deleteSuccessMessage"]').get_attribute( "innerHTML" ) expected_message = "Configuration template change initiated for AP(s)." print "Actual message = " + actual_message print "Expected message = " + expected_message # self.assertEqual(actual_message, expected_message, "Appropriate message '%s' is not displayed" % expected_message) except AssertionError as e: self.verificationErrors.append(str(e)) time.sleep(40) ####Checking for the default config running on AP. ssid = config_name expected_running_config_id = db.search_field_in_configuration_collection("_id", config_name) # Get the ap's jid ap_jid = utils.get_ap_jid(properties.real_ap_ip) print "AP jid return value is: " + ap_jid ap_jid = ap_jid.strip() actual_running_config_id = db.search_field_in_ap_collection("running_config_id", ap_jid) print "Actual running config id of AP is:" + str(actual_running_config_id) print "Expected running config id of AP is:" + str(expected_running_config_id) try: self.assertEqual( str(actual_running_config_id), str(expected_running_config_id), "Expected configuration %s is not running on %s AP." % (ssid, ap_jid), ) except AssertionError as e: self.verificationErrors.append(str(e)) # Verify if radios are enabled on the AP ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(properties.real_ap_ip, username="******", password="******") try: stdin, stdout, stderr = ssh.exec_command("uci show | grep disabled") except SSHException, e: print e data = stdout.readlines() for eachLine in data: if "radio0" in eachLine: radio_line = eachLine.split("\n") radio_state = radio_line[0] print "Actual Radio0 state is: " + radio_state expected_radio_state = "wireless.radio" + "0" + ".disabled=0" print "Expected radio state is: " + expected_radio_state try: self.assertEqual( radio_state.strip(), expected_radio_state, "After applying config to AP Radio0 was not disabled", ) except AssertionError as e: self.verificationErrors.append(str(e)) elif "radio1" in eachLine: radio_line = eachLine.split("\n") radio_state = radio_line[0] print "Actual Radio1 state is: " + radio_state expected_radio_state = "wireless.radio" + "1" + ".disabled=0" print "Expected radio state is: " + expected_radio_state try: self.assertEqual( radio_state.strip(), expected_radio_state, "After applying config to AP Radio1 was not disabled", ) except AssertionError as e: self.verificationErrors.append(str(e)) ###Checking for the SSID running on AP ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(properties.real_ap_ip, username="******", password="******") try: # To get the ssids running on AP (stdin, stdout, stderr) = ssh.exec_command("uci show | grep ssid") except SSHException, e: print e ssid_output = stdout.readlines() result = False cnt = 0 for num, each in enumerate(ssid_output): each = each.replace("\n", "") if cnt == 0: expected_ssid = "wireless.@wifi-iface[%s].ssid=%s" % (cnt, ssid) elif cnt == 1: expected_ssid = "wireless.@wifi-iface[%s].ssid=%s" % (cnt, ssid) cnt = cnt + 1 if expected_ssid == each: result = True print "Expected SSID is:" + expected_ssid print "Actual SSID is:" + each else: result = False print "Expected SSID is:" + expected_ssid print "Actual SSID is:" + each try: self.assertEqual(result, True, "Expected SSID %s is not running on AP." % ssid) except AssertionError as e: self.verificationErrors.append(str(e))
def delete_ap(self): columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][0]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][0]) driver.find_element_by_id("btnLogin").click() time.sleep(10) print "Clickin Customers dropdown" dropdown = driver.find_element_by_id("customerFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][1]: option.click() time.sleep(5) break else: continue driver.find_element_by_id("menuAccessPoints").click() time.sleep(5) i = 0 for option in driver.find_elements_by_css_selector("#ap_grid_table tbody tr"): client_name_id = "AP_Name_" + str(i) select_checkbox_id = "_" + str(i) if properties.ap_name == str(driver.find_element_by_css_selector("#" + client_name_id + " a").get_attribute('innerHTML')): print "AP Name = " + str(driver.find_element_by_css_selector('#' + client_name_id + ' a').get_attribute('innerHTML')) driver.find_element_by_css_selector("#" + select_checkbox_id + " div").click() time.sleep(5) driver.find_element_by_id("deleteApBtn").click() time.sleep(5) alert_text = driver.find_element_by_id("dialog-confirm").get_attribute("innerHTML") dialog_header = driver.find_element_by_id("ui-id-1").get_attribute("innerHTML").strip() self.assertEqual(dialog_header, "Delete the selected APs", "Delete AP Confirmation dialog not present!") driver.find_element_by_xpath("(//button[@type='button'])[1]").click() print "AP " + properties.ap_name + " deleted successfully!" #Verify if AP was deleted from ap collection db.verify_delete_ap(properties.ap_name) time.sleep(130) ap_jid = utils.get_ap_jid(properties.real_ap_ip) ap_jid = ap_jid.strip() #Verify if AP was added to new_ap collection db.search_ap_in_new_ap_collection(ap_jid) time.sleep(2) #Verify if radios are disabled on the AP ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(properties.real_ap_ip, username='******', password='******') stdin, stdout, stderr = ssh.exec_command("uci show | grep disabled") data = stdout.readlines() for eachLine in data: if "radio0" in eachLine: radio_line = eachLine.split("\n") radio_state = radio_line[0] print "Actual Radio0 state is: " + radio_state expected_radio_state = "wireless.radio" + "0" + ".disabled=1" print "Expected radio state is: " + expected_radio_state self.assertEqual(radio_state.strip(), expected_radio_state, "After deleting AP Radio0 was not disabled") for eachLine in data: if "radio1" in eachLine: radio_line = eachLine.split("\n") radio_state = radio_line[0] print "Actual Radio1 state is: " + radio_state expected_radio_state = "wireless.radio" + "1" + ".disabled=1" print "Expected radio state is: " + expected_radio_state self.assertEqual(radio_state.strip(), expected_radio_state, "After deleting AP Radio1 was not disabled") break else: continue i = i+1
def verify_apdetails_page(self): columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][0]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][0]) driver.find_element_by_id("btnLogin").click() time.sleep(30) print "Clicking VAR filter dropdown" dropdown = driver.find_element_by_id("varFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][0]: option.click() time.sleep(5) print "Clickin Customers dropdown" dropdown = driver.find_element_by_id("customerFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][1]: option.click() time.sleep(5) driver.find_element_by_id("menuAccessPoints").click() time.sleep(30) driver.find_element_by_link_text(properties.ap_name).click() time.sleep(10) #Verify VAR and Locaiton names on AP details page cust_location_name = driver.find_element_by_id("location").get_attribute('innerHTML') #Remove the <br> from the var and location name string for the AP cust_location_name = re.sub('<[^>]*>', '', cust_location_name) print "Actual Customer and Location name = " +str(cust_location_name) expected_cust_name = columns['var_business_name'][1] expected_location_name = columns['var_business_name'][2] expected_cust_location_name = expected_cust_name + expected_location_name print "Expected Var and Location name = " +str(expected_cust_location_name) self.assertEqual(cust_location_name, expected_cust_location_name, "Actual Customer and Location name is not same as expected!") #Verify AP name on the AP details page actual_ap_name = driver.find_element_by_id("apName").get_attribute('innerHTML') print "Actual AP Name = " +str(actual_ap_name) expected_ap_name = properties.ap_name self.assertEqual(actual_ap_name, expected_ap_name, "Actual AP name is not same as expected AP Name!") #Verify manufacturer name on AP details page manufacturer_name = driver.find_element_by_id("manufacture").get_attribute('innerHTML') print "Actual manufacturer of AP = " +str(manufacturer_name) expected_manufacturer = db.search_manufacturer_model_in_ap_collection(properties.ap_name) print "Expected manufacturer of AP = " +str(expected_manufacturer) self.assertEqual(manufacturer_name, expected_manufacturer, "Actual AP manufacturer is not same as expected AP manufacturer!") #Verify client count in the client widget client_widget = driver.find_element_by_id("client_count_value") actual_no_of_clients = client_widget.get_attribute('innerHTML') print "Actual no. of clients = " +str(actual_no_of_clients) expected_no_of_clients = utils.get_client_count() print "Expected no. of clients = " +str(expected_no_of_clients) self.assertEqual(actual_no_of_clients, expected_no_of_clients, "Actual no. of clients are not same as expected no. of clients!") #Verify AP traffic in the traffic guage chart traffic_widget = driver.find_element_by_id("traffic_value") actual_ap_traffic = traffic_widget.get_attribute('innerHTML') print "Actual AP traffic = " +str(actual_ap_traffic) ap_bytes_rx = utils.get_ap_stats("bytes_rx") ap_bytes_tx = utils.get_ap_stats("bytes_tx") expected_ap_traffic_mbps = utils.caluclate_apdetails_page_traffic_mbps(ap_bytes_rx, ap_bytes_tx) print "Expected AP traffic = " +expected_ap_traffic_mbps self.assertEqual(actual_ap_traffic, expected_ap_traffic_mbps, "Actual AP traffic is not same as Expected AP traffic!") #Verify 2.4G radio chan utilization in the guage chart chan_widget_24g = driver.find_element_by_id("utilization24G") chan_uti_24g = chan_widget_24g.get_attribute('innerHTML') print "Actual channel busy = " +str(chan_uti_24g) #Verify 5G radio chan utilization in the guage chart chan_widget_5g = driver.find_element_by_id("utilization5G") chan_uti_5g = chan_widget_5g.get_attribute('innerHTML') print "Actual channel busy = " +str(chan_uti_5g) channel_busy = utils.get_radio_utilization() print "Expected channel_busy = " +channel_busy self.assertEqual(chan_uti_24g, channel_busy, "Actual 24G channel utilization is not same as Expected 24G channel utilization!") self.assertEqual(chan_uti_5g, channel_busy, "Actual 5G channel utilization is not same as Expected 5G channel utilization!") time.sleep(2) for i in range(0, int(actual_no_of_clients)): client_name_id = "CLIENT_NAME_" + str(i) ssid_id = "SSID_" + str(i) usage_id = "USAGE_DATA__Kbps_" + str(i) rssi_id = "SIGNAL_STRENGTH__dBm_" + str(i) #Retrieve the name of the client mentioned in the static stats file which is in form of mac name = utils.get_client_name() #Extract last 3 subsets of the mac and compare with that in the Client name griD expected_client_substr = name[-8:] actual_client_name = driver.find_element_by_id(client_name_id).get_attribute('innerHTML') print "Actual client name = " +str(actual_client_name) print "Expected Client should contain: " +expected_client_substr #If the client matches get the client's rssi, usage and other values and verify them if expected_client_substr in actual_client_name: #Verify Rssi values of client actual_rssi = driver.find_element_by_css_selector("#" + rssi_id + " div").get_attribute('innerHTML') print "Actual Rssi value of the client = " +str(actual_rssi) expected_rssi = utils.get_client_stats("rssi") print "Expected Rssi value of the client = " +expected_rssi self.assertEqual(actual_rssi, expected_rssi, "Actual rssi of the client is not same as Expected rssi!") #Verify Essid values of client actual_essid = driver.find_element_by_id(ssid_id).get_attribute('innerHTML') print "Actual essid of the client = " +str(actual_essid) expected_essid = columns['var_business_name'][2] print "Expected essid of the client = " +str(expected_essid) self.assertEqual(actual_essid, expected_essid, "Actual essid of the client is not same as Expected essid!") #Verify Usage values of client actual_usage = driver.find_element_by_id(usage_id).get_attribute('innerHTML') print "Actual usage of the client = " +str(actual_usage) bytes_rx = utils.get_client_stats("bytes_rx") bytes_tx = utils.get_client_stats("bytes_tx") expected_usage = utils.caluclate_apdetails_page_client_usage_kbps(bytes_rx, bytes_tx) print "Expected usage of the client = " +str(expected_usage) self.assertEqual(int(actual_usage), int(expected_usage), "Actual usage of the client is not same as Expected usage!")
def verify_var_dashboard(self): columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][0]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][0]) driver.find_element_by_id("btnLogin").click() time.sleep(10) print "Clicking VAR filter dropdown" dropdown = driver.find_element_by_id("varFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][0]: option.click() time.sleep(5) def get_text_excluding_children(driver, element): return driver.execute_script(""" return jQuery(arguments[0]).contents().filter(function() { return this.nodeType == Node.TEXT_NODE; }).text(); """, element) #cust = get_text_excluding_children(driver, driver.find_element_by_css_selector("#cust_name_0")) for i in range (0, 10): cust_id = "#cust_name_" + str(i) #print cust_id cust = get_text_excluding_children(driver, driver.find_element_by_css_selector(cust_id)) cust = cust.strip() print cust if cust == columns['var_business_name'][1]: print "VAR dashboard details for the customer: " +cust location_id = "#location_" + str(i) + " h4" no_of_location = driver.find_element_by_css_selector(location_id).get_attribute("innerHTML").strip() print "No. of Locations = " +no_of_location exp_no_of_locs = 1 self.assertEqual(str(no_of_location), str(exp_no_of_locs), "No. of Location present under the customer are not as expected!") ap_up_id = "#ap_" + str(i) + " h4" no_of_aps_up = driver.find_element_by_css_selector(ap_up_id).get_attribute("innerHTML").strip() exp_no_of_aps_up = 1 print "No. of AP's that are Up = " +no_of_aps_up self.assertEqual(str(no_of_aps_up), str(exp_no_of_aps_up), "APs that are UP don't match the expected APs!") ap_down_id = "#apDown_" + str(i) + " h4" no_of_aps_down = driver.find_element_by_css_selector(ap_down_id).get_attribute("innerHTML").strip() exp_no_of_aps_down = 0 print "No. of AP's that are Down = " +no_of_aps_down self.assertEqual(str(no_of_aps_down), str(exp_no_of_aps_down), "APs that are down don't match the expected APs!") try: informative_event_id = "#Informative_" + str(i) + " span.eventCountBox" no_of_info_events = driver.find_element_by_css_selector(informative_event_id).get_attribute("innerHTML").strip() print "No. of Informative Events = " +no_of_info_events except NoSuchElementException: print "0 Informative Events!" try: critical_event_id = "#Critical_" + str(i) + " span.eventCountBox" no_of_critical_events = driver.find_element_by_css_selector(critical_event_id).get_attribute("innerHTML").strip() print "No. of Critical Events = " +no_of_critical_events except NoSuchElementException: print "0 Critical Events!" try: important_event_id = "#Important_" + str(i) + " span.eventCountBox" no_of_imp_events = driver.find_element_by_css_selector(important_event_id).get_attribute("innerHTML").strip() print "No. of Important Events = " +no_of_imp_events except NoSuchElementException: print "0 Important Events!" break else: continue
def _1_verify_apply_template_form(self): """This test case verifies fields and the data on Apply Template form """ columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][1]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][1]) driver.find_element_by_id("btnLogin").click() time.sleep(10) driver.find_element_by_id("menuAccessPoints").click() time.sleep(5) i = 0 for option in driver.find_elements_by_css_selector("#ap_grid_table tbody tr"): client_name_id = "AP_Name_" + str(i) select_checkbox_id = "_" + str(i) if properties.ap_name == str(driver.find_element_by_css_selector("#" + client_name_id + " a").get_attribute('innerHTML')): print "pass" driver.find_element_by_css_selector("#" + select_checkbox_id + " div").click() time.sleep(5) driver.find_element_by_id("applyTemplateBtn").click() time.sleep(3) ###Verifying the Selected APs table contents. j = 0 for option1 in driver.find_elements_by_css_selector("#selected_ap_list_table tbody tr"): selectedap_name_id = "AP_Name_" + str(j) location_id = "Location_" + str(j) actual_selected_ap_name = driver.find_element_by_id(selectedap_name_id).get_attribute('innerHTML') expected_selected_ap_name = properties.ap_name print "Actual selected AP name = " + actual_selected_ap_name print "Expected selected AP name = " + expected_selected_ap_name try: self.assertEqual(actual_selected_ap_name, expected_selected_ap_name, "Actual selected AP name is not same as Expected selected AP name!") except AssertionError as e: self.verificationErrors.append(str(e)) actual_selected_ap_location = driver.find_element_by_id(location_id).get_attribute('innerHTML') expected_selected_ap_location = columns['var_business_name'][2] print "Actual selected AP's location name = " + actual_selected_ap_location print "Expected selected AP's location name = " + expected_selected_ap_location try: self.assertEqual(actual_selected_ap_name, expected_selected_ap_name, "Actual selected AP's location name is not same as Expected selected AP's location name!") except AssertionError as e: self.verificationErrors.append(str(e)) ###Verifying the Selected AP's available templates table contents. j = 0 for option2 in driver.find_elements_by_css_selector("#config_list_table tbody tr"): template_name_id = "Template_name_" + str(j) ssid_id = "SSID_" + str(j) actual_template_name = driver.find_element_by_id(template_name_id).get_attribute('innerHTML') expected_template_name = properties.config_name print "Actual template name = " + actual_template_name print "Expected template name = " + expected_template_name try: self.assertEqual(actual_template_name, expected_template_name, "Actual template name is not same as Expected template name!") except AssertionError as e: self.verificationErrors.append(str(e)) actual_ssid_name = driver.find_element_by_id(ssid_id).get_attribute('innerHTML') expected_ssid_name = properties.config_name print "Actual template's SSID name = " + actual_ssid_name print "Expected template's SSID name = " + expected_ssid_name try: self.assertEqual(actual_ssid_name, expected_ssid_name, "Actual template's SSID name is not same as Expected Expected template's SSID name!") except AssertionError as e: self.verificationErrors.append(str(e))
def verify_apgrid(self): columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][0]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][0]) driver.find_element_by_id("btnLogin").click() time.sleep(10) print "Clicking VAR filter dropdown" dropdown = driver.find_element_by_id("varFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][0]: option.click() time.sleep(5) print "Clickin Customers dropdown" dropdown = driver.find_element_by_id("customerFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][1]: option.click() time.sleep(20) driver.find_element_by_id("menuAccessPoints").click() time.sleep(10) i = 0 for option in driver.find_elements_by_css_selector("#ap_grid_table tbody tr"): client_name_id = "AP_Name_" + str(i) location_id = "Location_" + str(i) template_id = "Template_" + str(i) mac_address_id = "MAC_Address_" + str(i) ip_address_id = "IP_Address_" + str(i) assoc_clients_id = "Associated_Clients_" + str(i) ap_model_id = "AP_Model_" + str(i) status_id = "Status_" + str(i) if properties.ap_name == str(driver.find_element_by_css_selector("#" + client_name_id + " a").get_attribute('innerHTML')): print "AP Name = " + str(driver.find_element_by_css_selector('#' + client_name_id + ' a').get_attribute('innerHTML')) actual_ap_location = driver.find_element_by_id(location_id).get_attribute('innerHTML') print "Actual location of the AP = " +actual_ap_location print "Expected location of the AP = " +columns['var_business_name'][2] self.assertEqual(actual_ap_location, columns['var_business_name'][2], "Actual location of the AP is not same as Expected location!") actual_config = driver.find_element_by_id(template_id).get_attribute('innerHTML') print "Actual config of the AP = " +actual_config print "Expected config of the AP = " +columns['var_business_name'][2] self.assertEqual(actual_config, columns['var_business_name'][2], "Actual config of the AP is not same as Expected config!") actual_mac = driver.find_element_by_id(mac_address_id).get_attribute('innerHTML') print "Actual MAC of the AP = " +actual_mac expected_mac = db.search_mac_in_ap_collection(properties.ap_name) print "Expected MAC of the AP = " +expected_mac self.assertEqual(actual_mac, expected_mac, "Actual MAC address of the AP is not same as Expected MAC address!") actual_ip = driver.find_element_by_id(ip_address_id).get_attribute('innerHTML') print "Actual IP of the AP = " +actual_ip expected_ip = db.search_ip_in_ap_collection(properties.ap_name) print "Expected IP of the AP = " +expected_ip self.assertEqual(actual_ip, expected_ip, "Actual AP address of the AP is not same as Expected AP address!") actual_no_of_clients = driver.find_element_by_id(assoc_clients_id).get_attribute('innerHTML') print "Actual Clients of the AP = " +actual_no_of_clients expected_no_of_clients = utils.get_client_count() print "Expected Clients of the AP = " +expected_no_of_clients self.assertEqual(actual_no_of_clients, expected_no_of_clients, "Actual Number of clients of the AP is not same as Expected clients!") actual_model = driver.find_element_by_id(ap_model_id).get_attribute('innerHTML') print "Actual model of the AP = " +actual_model expected_model = db.search_model_in_ap_collection(properties.ap_name) print "Expected model of the AP = " +expected_model self.assertEqual(actual_model, expected_model, "Actual Model of the AP is not same as Expected Model!") actual_ap_status = driver.find_element_by_css_selector('#' + status_id + ' img').get_attribute('title') print "Actual status of the AP = " +actual_ap_status expected_ap_status = 'available' print "Expected status of the AP = " +expected_ap_status self.assertEqual(actual_ap_status, expected_ap_status, "AP is in Not Available status!") i = i+1
def verify_customer_dashboard(self): columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][0]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][0]) driver.find_element_by_id("btnLogin").click() time.sleep(10) print "Clicking VAR filter dropdown" dropdown = driver.find_element_by_id("varFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][0]: option.click() time.sleep(5) print "Clickin Customers dropdown" dropdown = driver.find_element_by_id("customerFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][1]: option.click() time.sleep(5) for i in range(0, 1): top5_device_id = "top_devices_" + str(i) #Retrieve the name of the client mentioned in the static stats file which is in form of mac name = utils.get_client_name() #Extract last 3 subsets of the mac and compare with that in the Client name griD expected_client_substr = name[-8:] actual_client_name = driver.find_element_by_css_selector('#' + top5_device_id + ' a').get_attribute('innerHTML').strip() print "Actual client name = " +str(actual_client_name) print "Expected Client should contain: " +expected_client_substr if expected_client_substr in actual_client_name: actual_client_traffic = driver.find_element_by_css_selector('#' + top5_device_id + ' div.overviewTableTextSecondary').get_attribute('innerHTML') print "Actual Top 5 Devices traffic = " +str(actual_client_traffic) bytes_rx = utils.get_client_stats("bytes_rx") bytes_tx = utils.get_client_stats("bytes_tx") expected_client_traffic = utils.caluclate_cust_dashboard_top5devices_traffic_kbps(bytes_rx, bytes_tx) print "Expected Top 5 Devices traffic = " +str(expected_client_traffic) self.assertEqual(actual_client_traffic, expected_client_traffic, "Actual traffic of the Top 5 Devices is not same as Expected traffic!") break else: continue for i in range(0, 1): top5_ssid_id = "top_ssid_" + str(i) expected_ssid_name = columns['var_business_name'][2] actual_ssid_name = driver.find_element_by_css_selector('#' + top5_ssid_id + ' a').get_attribute('innerHTML').strip() print "Actual SSID name = " +str(actual_ssid_name) print "Expected SSID name = " +expected_ssid_name if expected_ssid_name == actual_ssid_name: actual_ssid_traffic = driver.find_element_by_css_selector('#' + top5_ssid_id + ' div.overviewTableTextSecondary').get_attribute('innerHTML') print "Actual Top 5 SSIDs traffic = " +str(actual_ssid_traffic) bytes_rx = utils.get_ap_stats("bytes_rx") bytes_tx = utils.get_ap_stats("bytes_tx") expected_ssid_traffic = utils.caluclate_cust_dashboard_top5ssids_traffic_kbps(bytes_rx, bytes_tx) print "Expected Top 5 SSIDs traffic = " +expected_ssid_traffic self.assertEqual(actual_ssid_traffic, expected_ssid_traffic, "Actual traffic of the Top 5 SSIDs is not same as Expected traffic!") break else: continue for i in range(0, 1): top5_ap_id = "top_ap_" + str(i) expected_ap_name = properties.ap_name actual_ap_name = driver.find_element_by_css_selector('#' + top5_ap_id + ' a').get_attribute('innerHTML').strip() print "Actual AP name = " +str(actual_ap_name) print "Expected AP name = " +expected_ap_name if expected_ap_name == actual_ap_name: actual_ap_traffic = driver.find_element_by_css_selector('#' + top5_ap_id + ' div.overviewTableTextSecondary').get_attribute('innerHTML') print "Actual Top 5 APs traffic = " +str(actual_ap_traffic) bytes_rx = utils.get_ap_stats("bytes_rx") bytes_tx = utils.get_ap_stats("bytes_tx") expected_ap_traffic = utils.caluclate_cust_dashboard_top5aps_traffic_kbps(bytes_rx, bytes_tx) print "Expected Top 5 APs traffic = " +expected_ap_traffic self.assertEqual(actual_ap_traffic, expected_ap_traffic, "Actual traffic of the Top 5 APs is not same as Expected traffic!") break else: continue
def verify_location_dashboard(self): columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][0]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][0]) driver.find_element_by_id("btnLogin").click() time.sleep(10) print "Clicking VAR filter dropdown" dropdown = driver.find_element_by_id("varFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][0]: option.click() time.sleep(5) print "Clickin Customers dropdown" dropdown = driver.find_element_by_id("customerFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][1]: option.click() time.sleep(5) print "Clickin Location dropdown" dropdown = driver.find_element_by_id("locationFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][2]: option.click() time.sleep(5) #Verify client count in the client widget client_widget = driver.find_element_by_id("client_count_value") actual_no_of_clients = client_widget.get_attribute('innerHTML') print "Actual no. of clients = " +str(actual_no_of_clients) expected_no_of_clients = utils.get_client_count() print "Expected no. of clients = " +str(expected_no_of_clients) self.assertEqual(actual_no_of_clients, expected_no_of_clients, "Actual no. of clients are not same as expected no. of clients!") #Verify AP traffic in the traffic guage chart traffic_widget = driver.find_element_by_id("traffic_value") actual_ap_traffic = traffic_widget.get_attribute('innerHTML') print "Actual AP traffic = " +str(actual_ap_traffic) ap_bytes_rx = utils.get_ap_stats("bytes_rx") ap_bytes_tx = utils.get_ap_stats("bytes_tx") expected_ap_traffic_mbps = utils.caluclate_loc_dashboard_traffic_mbps(ap_bytes_rx, ap_bytes_tx) print "Expected AP traffic = " +expected_ap_traffic_mbps self.assertEqual(actual_ap_traffic, expected_ap_traffic_mbps, "Actual AP traffic is not same as Expected AP traffic!") #Verify 2.4G radio chan utilization in the guage chart chan_widget_24g = driver.find_element_by_id("utilization24G") chan_uti_24g = chan_widget_24g.get_attribute('innerHTML') print "Actual channel busy = " +str(chan_uti_24g) #Verify 5G radio chan utilization in the guage chart chan_widget_5g = driver.find_element_by_id("utilization5G") chan_uti_5g = chan_widget_5g.get_attribute('innerHTML') print "Actual channel busy = " +str(chan_uti_5g) channel_busy = utils.get_radio_utilization() print "Expected channel_busy = " +channel_busy self.assertEqual(chan_uti_24g, channel_busy, "Actual 24G channel utilization is not same as Expected 24G channel utilization!") self.assertEqual(chan_uti_5g, channel_busy, "Actual 5G channel utilization is not same as Expected 5G channel utilization!") time.sleep(2) for i in range(0, int(actual_no_of_clients)): top5_device_id = "top_devices_" + str(i) #Retrieve the name of the client mentioned in the static stats file which is in form of mac name = utils.get_client_name() #Extract last 3 subsets of the mac and compare with that in the Client name griD expected_client_substr = name[-8:] actual_client_name = driver.find_element_by_css_selector('#' + top5_device_id + ' a').get_attribute('innerHTML').strip() print "Actual client name = " +str(actual_client_name) print "Expected Client should contain: " +expected_client_substr if expected_client_substr in actual_client_name: actual_client_traffic = driver.find_element_by_css_selector('#' + top5_device_id + ' div.overviewTableTextSecondary').get_attribute('innerHTML') print "Actual Top 5 Devices traffic = " +str(actual_client_traffic) bytes_rx = utils.get_client_stats("bytes_rx") bytes_tx = utils.get_client_stats("bytes_tx") expected_client_traffic = utils.caluclate_loc_dashboard_top5devices_traffic_kbps(bytes_rx, bytes_tx) print "Expected Top 5 Devices traffic = " +str(expected_client_traffic) self.assertEqual(actual_client_traffic, expected_client_traffic, "Actual traffic of the Top 5 Devices is not same as Expected traffic!") break else: continue for i in range(0, 1): top5_ssid_id = "top_ssid_" + str(i) expected_ssid_name = columns['var_business_name'][2] actual_ssid_name = driver.find_element_by_css_selector('#' + top5_ssid_id + ' a').get_attribute('innerHTML').strip() print "Actual SSID name = " +str(actual_ssid_name) print "Expected SSID name = " +expected_ssid_name if expected_ssid_name == actual_ssid_name: actual_ssid_traffic = driver.find_element_by_css_selector('#' + top5_ssid_id + ' div.overviewTableTextSecondary').get_attribute('innerHTML') print "Actual Top 5 SSIDs traffic = " +str(actual_ssid_traffic) bytes_rx = utils.get_ap_stats("bytes_rx") bytes_tx = utils.get_ap_stats("bytes_tx") expected_ssid_traffic = utils.caluclate_loc_dashboard_top5ssids_traffic_kbps(bytes_rx, bytes_tx) print "Expected Top 5 SSIDs traffic = " +expected_ssid_traffic self.assertEqual(actual_ssid_traffic, expected_ssid_traffic, "Actual traffic of the Top 5 SSIDs is not same as Expected traffic!") break else: continue for i in range(0, 1): top5_ap_id = "top_ap_" + str(i) expected_ap_name = properties.ap_name actual_ap_name = driver.find_element_by_css_selector('#' + top5_ap_id + ' a').get_attribute('innerHTML').strip() print "Actual AP name = " +str(actual_ap_name) print "Expected AP name = " +expected_ap_name if expected_ap_name == actual_ap_name: actual_ap_traffic = driver.find_element_by_css_selector('#' + top5_ap_id + ' div.overviewTableTextSecondary').get_attribute('innerHTML') print "Actual Top 5 APs traffic = " +str(actual_ap_traffic) bytes_rx = utils.get_ap_stats("bytes_rx") bytes_tx = utils.get_ap_stats("bytes_tx") expected_ap_traffic = utils.caluclate_loc_dashboard_top5aps_traffic_kbps(bytes_rx, bytes_tx) print "Expected Top 5 APs traffic = " +expected_ap_traffic self.assertEqual(actual_ap_traffic, expected_ap_traffic, "Actual traffic of the Top 5 APs is not same as Expected traffic!") break else: continue