def Click_CheckBox(self): selenium.type("id=" + config_element.get("detail_message", "serial_number_name"), config_setting.get("setting", "serial_number")) for keyDown in range(18): pyautogui.keyDown('tab') for key_down in range(19): pyautogui.keyDown('down')
def login(self): selenium = self.selenium selenium.open("/") selenium.click("login") selenium.wait_for_page_to_load(5000) selenium.type("email", "*****@*****.**") selenium.click("submit-login") selenium.wait_for_page_to_load(5000)
def doMemberLogin(self, usernameOrEmail, password): selenium = self.selenium selenium.click("menu-login") selenium.wait_for_page_to_load("30000") selenium.type("username", usernameOrEmail) selenium.type("password", password) selenium.click("login") selenium.wait_for_page_to_load("30000") self.assertEqual("page-home-member", selenium.get_attribute("//body@id"))
def HeNS_Request_Message(self, boolean, heMS_SetParameterValues): # try: pyautogui.click(1000, 30) self.System_Operation_Data() self.Click_Serial_Number() # Click the Message Log # selenium.click( "link="+config_element.get("system", "system_message_log")) # Refresh the list content for refresh in range(2): selenium.click( "xpath="+config_element.get("system", "system_refresh_button")) # Select the HeMS detail message print 'Type the serial number.' self.Click_CheckBox() selenium.type("id="+config_element.get("detail_message", "search_askey_root"), config_element.get("detail_message", "input_askey_root")) time.sleep(3) selenium.click( "xpath="+config_element.get("detail_message", "search_button")) print "Select the key code" # Verify the SetParameterValues text can be get setParameterValues = selenium.get_text( "xpath="+config_element.get("detail_message", "parametervalues_text")) if setParameterValues == 'SetParameterValues': print 'Get the SetParameterValues text!!' else: print "Do not Get the SetParameterValues text!!" android = Android() android.Copy_Trace_Folder() raise Exception("Do not Get the SetParameterValues text!!") self.Autoit_Detail_Message(40) # Get the message from Get_clipboard message_log_detail_dialog = self.Get_Clipboard() # Verify the boolean value if '<Value xsi:type="boolean">' + boolean + '</Value>' in message_log_detail_dialog: print 'The boolean was matched - SUCCESS' elif '<Value xsi:type="boolean">' + 'true' + '</Value>' in message_log_detail_dialog: print 'The boolean was matched - SUCCESS' elif '<Value xsi:type="boolean">' + 'false' + '</Value>' in message_log_detail_dialog: print 'The boolean was matched - SUCCESS' else: print "The boolean was not matched - FAIL" android = Android() android.Copy_Trace_Folder() raise Exception("The boolean was not matched - FAIL") time.sleep(1) now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time())) heMS_SetParameterValues = heMS_SetParameterValues + '_' + now + '.txt' fp = open(heMS_SetParameterValues, "w") fp.write(message_log_detail_dialog) autoit.Sleep(1000) autoit.Send("!{F4}") print "Close the Detail page"
def testGoogle__4(self): selenium = self.selenium selenium.open("http://www.google.com/webhp?hl=en") #Verifies that the title matches self.assertEqual ("Google", selenium.get_title()) selenium.type("q", "Selenium OpenQA") #Verifies that it can find the Selenium website self.assertEqual("Selenium OpenQA", selenium.get_value("q")) selenium.click("btnG") selenium.wait_for_page_to_load("5000") self.assertEqual("Selenium OpenQA - Google Search", selenium.get_title())
def testGoogle__4(self): selenium = self.selenium selenium.open("http://www.google.com/webhp?hl=en") #Verifies that the title matches self.assertEqual("Google", selenium.get_title()) selenium.type("q", "Selenium OpenQA") #Verifies that it can find the Selenium website self.assertEqual("Selenium OpenQA", selenium.get_value("q")) selenium.click("btnG") selenium.wait_for_page_to_load("5000") self.assertEqual("Selenium OpenQA - Google Search", selenium.get_title())
def Login(self): try: selenium.open(config_element.get("setting", "acs_address_sub")) selenium.type("id="+config_element.get("login", "username_id"), config_setting.get("setting", "username")) selenium.type("id="+config_element.get("login", "password_id"), config_setting.get("setting", "password")) selenium.click("id="+config_element.get("login", "login_Id")) selenium.wait_for_page_to_load( config_element.get("setting", "wait_time")) print "Login to the web - PASS" pyautogui.click(1000, 30) selenium.click( "xpath="+config_element.get("setting", "askey_logo")) print "Get the ASKEY image - PASS" except: raise Exception("No login to the web - FAIL")
def Set_Value(self, boolean): if boolean == '0': # change the parameter value boolean to 0 # time.sleep(1) selenium.type("css="+config_element.get("adminstate", "adminstate_value"), config_element.get("adminstate", "boolean_false")) time.sleep(1) print 'The value was change to ' + boolean selenium.click("xpath="+config_element.get("adminstate", "adminstate_set_value_button")) if boolean == '1': # change the parameter value boolean to 1 # time.sleep(1) selenium.type("css="+config_element.get("adminstate", "adminstate_value"), config_element.get("adminstate", "boolean_true")) time.sleep(1) print 'The value was change to ' + boolean selenium.click("xpath="+config_element.get("adminstate", "adminstate_set_value_button"))
def Add_All_Devices(self): try: self.System_Operation_Data() selenium.click( "xpath="+config_element.get("add_file", "click_add_button")) for add_file_times in range(0, 1): print "The " + str(add_file_times+1) + " add the file" time.sleep(1) selenium.click( "name="+config_element.get("add_file", "downframe")) selenium.type("xpath="+config_element.get("add_file", "oui_text"), config_setting.get("add_file", "oui_value")) selenium.type("xpath="+config_element.get("add_file", "product_class"), config_setting.get("add_file", "product_value")) selenium.type("xpath="+config_element.get("add_file", "serial_number"), config_setting.get("add_file", "serial_number") + " - " + str(add_file_times+1)) selenium.click( "css="+config_element.get("add_file", "submit_button")) ################### Verify the success message ################ selenium.click( "name="+config_element.get("add_file", "downframe")) add_cpe_successfully = selenium.get_text( "xpath="+config_element.get("add_file", "add_cpe_successfully")) if add_cpe_successfully == "The CPE has exsited.": print add_cpe_successfully elif add_cpe_successfully == "Add successfully.": print add_cpe_successfully else: raise Exception("Add file was not success") print "Add the file - PASS" except: raise Exception("Add the file was not success")
def Parameter_List_PLMN(self, checkbox, location, value): try: self.System_Operation_Data() self.Click_Serial_Number() selenium.click( "link="+config_element.get("system", "system_parameter_list")) time.sleep(2) print "Click the Parameter List" selenium.click("link="+config_element.get("PLMN","plmnlist_location")) selenium.click("xpath="+config_element.get("PLMN","plmnid_location")) selenium.click("xpath="+checkbox) selenium.click("xpath="+location) selenium.type("xpath="+location,value) selenium.click("xpath="+config_element.get("PLMN","plmnid_set_value_button")) time.sleep(2) # successfully_request_to_message_queue = selenium.get_text( # "xpath="+config_element.get("PLMN", "parameter_value_successfully_folder")) # if successfully_request_to_message_queue == "Successfully add SetParameterValues request to the Message Queue": # print successfully_request_to_message_queue # else: # raise Exception("Get value was not success") except Exception as e: raise e
def testMemberViewsAndEditsHisAccountSettings(self): ''' Member views and edits his account settings. Persistance is tested by changing the about field twice and verifying the saved input ''' selenium = self.selenium self.preconditionLoggedIn() selenium.open("/") selenium.wait_for_page_to_load("30000") selenium.click("sidebarMenu-accountSettings") selenium.wait_for_page_to_load("30000") self.assertEqual("page-account-view", selenium.get_attribute("//body@id")) selenium.click("btnEditAccount") selenium.wait_for_page_to_load("30000") self.assertEqual("page-account-edit", selenium.get_attribute("//body@id")) selenium.type("About", "Bonjour!") selenium.click("btnSave") selenium.wait_for_page_to_load("30000") self.assertEqual("page-account-view", selenium.get_attribute("//body@id")) self.assertEqual("Bonjour!", selenium.get_text("valAbout")) selenium.click("btnEditAccount") selenium.wait_for_page_to_load("30000")
def testMemberChangePassword(self): ''' Member logs in with the default password, changes his password, then logs out and logs back in with the new password. Afterward, the member changes back the password to the default. ''' def browseToChangePasswordFromHome(): selenium.click("sidebarMenu-accountSettings") selenium.wait_for_page_to_load("30000") self.assertEqual("page-account-view", selenium.get_attribute("//body@id")) selenium.click("sidebarMenu-changePassword") selenium.wait_for_page_to_load("30000") self.assertEqual("page-account-changePassword", selenium.get_attribute("//body@id")) selenium = self.selenium self.preconditionLoggedIn() browseToChangePasswordFromHome() selenium.type("oldPassword", self.testMemberPassword) selenium.type("newPassword", self.testMemberAlternatePassword) selenium.click("save") selenium.wait_for_page_to_load("30000") self.assertEqual("page-account-view", selenium.get_attribute("//body@id")) self.doMemberLogout() self.doMemberLogin(self.testMemberUsername, self.testMemberAlternatePassword) browseToChangePasswordFromHome() selenium.type("oldPassword", self.testMemberAlternatePassword) selenium.type("newPassword", self.testMemberPassword) selenium.click("save") selenium.wait_for_page_to_load("30000") self.assertEqual("page-account-view", selenium.get_attribute("//body@id")) self.doMemberLogout() self.doMemberLogin(self.testMemberUsername, self.testMemberPassword) def browseToChangePasswordFromHome(): selenium.click("sidebarMenu-accountSettings") selenium.wait_for_page_to_load("30000") self.assertEqual("page-account-view", selenium.get_attribute("//body@id")) selenium.click("sidebarMenu-changePassword") selenium.wait_for_page_to_load("30000") self.assertEqual("page-account-changePassword", selenium.get_attribute("//body@id"))
def Set_Value_By_Earfcn(self, earfcn): selenium.click("xpath="+config_element.get("Earfcn","earfcnDL_checkbox")) selenium.type("xpath="+config_element.get("Earfcn","earfcnDL_value"),earfcn) selenium.click("xpath="+config_element.get("Earfcn","earfcnUL_checkbox")) selenium.type("xpath="+config_element.get("Earfcn","earfcnUL_value"),earfcn) selenium.click("xpath="+config_element.get("Earfcn","earfcn_set_value_button"))