How to use alert_wait method in Airtest

Best Python code snippet using Airtest

base.py

Source:base.py Github

copy

Full Screen

...62 objectNames = self.selenium.find_elements_by_id(elementId)63 print('%s%s%s' % (['{}'.format(objectName.text) for objectName in objectNames], " found in ", elementId) if len(objectNames) > 0 else ('%s%s%s' % ("----waiting for ", elementId, ' to update.')))64 self.assertIn(targetText, ['{}'.format(objectName.text) for objectName in objectNames]) 65 66 def alert_wait(self):67 browser = self.selenium68 try:69 WebDriverWait(browser, 10).until(EC.alert_is_present(),70 'Timed out waiting for PA creation ' +71 'confirmation popup to appear.')72 except:73 raise TimeoutException("Process timed out!")74 traceback.print_exc()75 print("Alert box not present!")76 def elementID_wait(self, elementID):77 browser = self.selenium78 try:79 WebDriverWait(browser, 30).until(EC.presence_of_element_located((By.ID, elementID)))80 except:81 raise TimeoutException("Process timed out!")82 traceback.print_exc()83 print('Element not present -> {}'.format(elementID))84 # close notifications85 def closeNotifications(self):86 for i in (self.selenium.find_elements_by_id('closeNotification')):87 i.click()88# Insert new object into UserToDo89 def insert_Login(self, 90 object_userName, 91 object_password, 92 date=None,93 failure=None):94 # User searches for inputs to name, email and date into input fields and submits information95 username_input = self.selenium.find_element_by_id('id_username')96 password_input = self.selenium.find_element_by_id('id_password')97 # date_input = self.selenium.find_element_by_id('addObject_date')98 submit = self.selenium.find_element_by_id('submit_login')99 username_input.send_keys(object_userName)100 password_input.send_keys(object_password)101 # date_input.send_keys(date)102 submit.submit()103 # Insert new object into UserToDo104 def insert_UserToDo(self, 105 object_subject, 106 object_toDoProgress, 107 date=None,108 failure=None):109 # User clicks on add object button to toggle form110 print("{}{}".format("addObject:", self.selenium.find_element_by_id('addObject')))111 self.selenium.find_element_by_id('addObject').click()112 # User searches for inputs to name, email and date into input fields and submits information113 subject_input = self.selenium.find_element_by_id('userToDoForm_subject')114 toDoProgress_input = self.selenium.find_element_by_id('userToDoForm_toDoProgress')115 # date_input = self.selenium.find_element_by_id('addObject_date')116 submit = self.selenium.find_element_by_id('addUserToDo_Submit')117 subject_input.send_keys(object_subject)118 toDoProgress_input.send_keys(object_toDoProgress)119 # date_input.send_keys(date)120 submit.submit()121 # Information correct?122 self.alert_wait()123 alertObj = self.selenium.switch_to.alert124 alertObj.accept()125 if (failure == False): 126 # Success notification127 self.wait_for_(lambda: self.find_object_by_id("notification", "You have new objectives!"))128 # Refresh results to view129 self.wait_for_(lambda: self.find_object_by_id("notification", "Refresh page to view changes!"))130 self.closeNotifications()131 # Insert new object into UserToDo132 def edit_UserToDo(self, 133 object_subject, 134 object_toDoProgress, 135 date=None):136 # User searches for inputs to name, email and date into input fields and submits information137 subject_input = self.selenium.find_element_by_id('editUserToDo_subject')138 toDoProgress_input = self.selenium.find_element_by_id('editUserToDo_toDoProgress')139 submit = self.selenium.find_element_by_id('edit_UserToDo_Submit')140 subject_input.clear()141 subject_input.send_keys(object_subject)142 toDoProgress_input.send_keys(object_toDoProgress)143 # date_input.send_keys(date)144 submit.submit()145 # Information correct?146 self.alert_wait()147 alertObj = self.selenium.switch_to.alert148 alertObj.accept()149 # Success notification150 self.wait_for_(lambda: self.find_object_by_id("notification", "Your objective was modified successfully!"))151 # Refresh results to view152 self.wait_for_(lambda: self.find_object_by_id("notification", "Refresh page to view changes!"))153 self.closeNotifications()154 print("def insert_NewObject -> complete")155 # Insert new object into UserNote156 def insert_UserNote(self, 157 object_taskNote, 158 object_noteProgress, 159 date=None,160 failure=None):161 # User identifies, inserts and submits User Note Data162 noteProgress = self.selenium.find_element_by_id('userNoteForm_noteProgress')163 taskNote = self.selenium.find_element_by_id('userNoteForm_taskNote')164 submit = self.selenium.find_element_by_id('addUserNote_Submit')165 noteProgress.send_keys(object_noteProgress)166 taskNote.send_keys(object_taskNote)167 submit.submit()168 # Information correct?169 self.alert_wait()170 alertObj = self.selenium.switch_to.alert171 alertObj.accept()172 # If UserNote is not expecting a failure173 if (failure == False): 174 # Success notification175 self.wait_for_(lambda: self.find_object_by_id("notification", "Your objective has things to do!"))176 # Refresh results to view177 self.wait_for_(lambda: self.find_object_by_id("notification", "Refresh page to view changes!"))178 self.closeNotifications()179 180 print("def insert_UserNote -> complete")181 return True182 # Insert new object into UserNote183 def edit_UserNote(self, 184 object_taskNote, 185 object_noteProgress, 186 date=None):187 time.sleep(1)188 # User identifies, inserts and submits User Note Data189 taskNote_input = self.selenium.find_element_by_id('editUserNote_taskNote')190 noteProgress_input = self.selenium.find_element_by_id('editUserNote_noteProgress')191 submit = self.selenium.find_element_by_id('edit_UserNote_Submit')192 taskNote_input.clear()193 taskNote_input.send_keys(object_taskNote)194 noteProgress_input.send_keys(object_noteProgress)195 submit.submit()196 # Information correct?197 self.alert_wait()198 alertObj = self.selenium.switch_to.alert199 alertObj.accept()200 # Success notification201 self.wait_for_(lambda: self.find_object_by_id("notification", "Your task was modified successfully!"))202 # Refresh results to view203 self.wait_for_(lambda: self.find_object_by_id("notification", "Refresh page to view changes!"))204 self.closeNotifications()205 print("def insert_UserNote -> complete")206 return True207 # Insert new object into UserNote208 def insert_NoteDescription(self, 209 object_noteDescription, 210 object_noteDescriptionProgress, 211 date=None):212 # User identifies, inserts and submits User Note Data213 noteDescription = self.selenium.find_element_by_id('noteDescriptionForm_description')214 noteDescrptionProgress = self.selenium.find_element_by_id('noteDescriptionForm_noteDescriptionProgress')215 submit = self.selenium.find_element_by_id('addNoteDescription_Submit')216 noteDescription.send_keys(object_noteDescription)217 noteDescrptionProgress.send_keys(object_noteDescriptionProgress)218 submit.submit()219 # Information correct?220 self.alert_wait()221 alertObj = self.selenium.switch_to.alert222 alertObj.accept()223 # Success notification224 self.wait_for_(lambda: self.find_object_by_id("notification", "Your task has a new note!"))225 # Refresh results to view226 self.wait_for_(lambda: self.find_object_by_id("notification", "Refresh page to view changes!"))227 self.closeNotifications()228 print("def insert_NoteDescription -> complete")229 return True230 # Insert new object into UserNote231 def edit_NoteDescription(self, 232 object_noteDescription, 233 object_noteDescriptionProgress, 234 date=None):235 # User identifies, inserts and submits User Note Data236 noteDescription = self.selenium.find_element_by_id('editNoteDescriptionForm_description')237 noteDescrptionProgress = self.selenium.find_element_by_id('editNoteDescriptionForm_noteDescriptionProgress')238 submit = self.selenium.find_element_by_id('edit_NoteDescription_Submit')239 noteDescription.clear()240 noteDescription.send_keys(object_noteDescription)241 noteDescrptionProgress.send_keys(object_noteDescriptionProgress)242 submit.submit()243 # Information correct?244 self.alert_wait()245 alertObj = self.selenium.switch_to.alert246 alertObj.accept()247 # Success notification248 self.wait_for_(lambda: self.find_object_by_id("notification", "Your task has a new note!"))249 # Refresh results to view250 self.wait_for_(lambda: self.find_object_by_id("notification", "Refresh page to view changes!"))251 self.closeNotifications()252 print("def insert_NoteDescription -> complete")253 return True254 # Insert new Production Meeting255 def insert_ProductionMeeting(self, object_subject, date=None):256 # User clicks on addProductionForm button to toggle form257 print("{}{}".format("addProduction:", self.selenium.find_element_by_id('addProduction')))258 self.selenium.find_element_by_id('addProduction').click()259 time.sleep(1)260 self.selenium.find_element_by_id('insertProductionMeeting_heading').click()261 262 # User searches for inputs to name, email and date into input fields and submits information263 subject_input = self.selenium.find_element_by_id('ProductionMeetingForm_subject')264 # date_input = self.selenium.find_element_by_id('addObject_date')265 submit = self.selenium.find_element_by_id('add_ProductionMeeting_Submit')266 subject_input.send_keys(object_subject)267 # date_input.send_keys(date)268 submit.submit()269 # Information correct?270 self.alert_wait()271 alertObj = self.selenium.switch_to.alert272 alertObj.accept()273 # Refresh message274 self.alert_wait()275 alertObj = self.selenium.switch_to.alert276 alertObj.accept()277 # Refresh production list because refreshObject set to false278 # self.selenium.find_element_by_id('refreshProductionList').click()279 print("def insert_ProductionMeeting -> complete")280 # Edit existing Production Meeting281 def edit_ProductionMeeting(self, object_subject, date=None):282 # User clicks on editProductionMeeting button to toggle form283 self.selenium.find_element_by_id('editProductionMeeting_Toggle').click()284 self.wait_for_(lambda: self.find_object_by_id("editProductionMeeting_header", "Change the subject of this production meeting."))285 # User searches for inputs to name, email and date into input fields and submits information286 subject_input = self.selenium.find_element_by_id('Edit_ProductionMeetingForm_subject')287 # date_input = self.selenium.find_element_by_id('addObject_date')288 submit = self.selenium.find_element_by_id('edit_ProductionMeeting_Submit')289 subject_input.clear()290 subject_input.send_keys(object_subject)291 # date_input.send_keys(date)292 submit.submit()293 # Information correct?294 self.alert_wait()295 alertObj = self.selenium.switch_to.alert296 alertObj.accept()297 # Refresh message298 self.alert_wait()299 alertObj = self.selenium.switch_to.alert300 alertObj.accept() 301 # Refresh production list because refreshObject set to false302 # self.selenium.find_element_by_id('refreshProductionList').click()303 print("def edit_ProductionMeeting -> complete")304 # Insert new production note305 def insert_ProductionNote(self, object_subject, date=None):306 # User clicks on addProductionNote_Toggle button to toggle form307 self.selenium.find_element_by_id('addProductionNote_Toggle').click()308 # User searches for inputs to name, email and date into input fields and submits information309 prodNote_input = self.selenium.find_element_by_id('ProductionNoteForm_prodNote')310 # date_input = self.selenium.find_element_by_id('addObject_date')311 submit = self.selenium.find_element_by_id('addProductionNote_Submit')312 prodNote_input.send_keys(object_subject)313 # date_input.send_keys(date)314 submit.submit()315 # Information correct?316 self.alert_wait()317 alertObj = self.selenium.switch_to.alert318 alertObj.accept()319 # Refresh message320 self.alert_wait()321 alertObj = self.selenium.switch_to.alert322 alertObj.accept() 323 print("def insert_ProductionNote -> complete")324 # edit existing production note325 def edit_ProductionNote(self, object_subject, date=None):326 # User clicks on addProductionNote_Toggle button to toggle form327 self.selenium.find_element_by_id('editProductionNote_Toggle').click()328 self.wait_for_(lambda: self.find_object_by_id("editProductionNote_header", "Change the information of this production note."))329 # User searches for inputs to name, email and date into input fields and submits information330 prodNote_input = self.selenium.find_element_by_id('Edit_ProductionNoteForm_prodNote')331 # date_input = self.selenium.find_element_by_id('addObject_date')332 submit = self.selenium.find_element_by_id('edit_ProductionNote_Submit')333 prodNote_input.clear()334 prodNote_input.send_keys(object_subject)335 # date_input.send_keys(date)336 submit.submit()337 # Information correct?338 self.alert_wait()339 alertObj = self.selenium.switch_to.alert340 alertObj.accept()341 # Refresh message342 self.alert_wait()343 alertObj = self.selenium.switch_to.alert344 alertObj.accept() 345 print("def insert_ProductionNote -> complete")346 # Insert new CustomerID347 def insert_CustomerID(self, 348 object_customerCode, 349 object_customerName, 350 object_procurementName, 351 object_procurementWorkNum,352 object_procurementEmail, 353 object_technicalName,354 object_technicalWorkNum, 355 object_technicalWorkEmail,356 object_customerStatus,357 object_customerType):358 # User clicks on addDeliveryRoute button to toggle form and DeliveryPlan tag359 print("{}{}".format("addProduction:", self.selenium.find_element_by_id('addProduction')))360 self.selenium.find_element_by_id('addDeliveryRouteForm').click() 361 self.selenium.find_element_by_id('addCustomerID').click()362 customerCode_input = self.selenium.find_element_by_id('CustomerIDForm_customerCode')363 customerName_input = self.selenium.find_element_by_id('CustomerIDForm_customerName')364 procurementName_input = self.selenium.find_element_by_id('CustomerIDForm_procurementName')365 procurementWorkNum_input = self.selenium.find_element_by_id('CustomerIDForm_procurementWorkNum')366 procurementWorkEmail_input = self.selenium.find_element_by_id('CustomerIDForm_procurementWorkEmail')367 technicalName_input = self.selenium.find_element_by_id('CustomerIDForm_technicalName')368 technicalWorkNum_input = self.selenium.find_element_by_id('CustomerIDForm_technicalWorkNum')369 technicalWorkEmail_input = self.selenium.find_element_by_id('CustomerIDForm_technicalWorkEmail')370 customerStatus_input = self.selenium.find_element_by_id('CustomerIDForm_customerStatus')371 customerType_input = self.selenium.find_element_by_id('CustomerIDForm_customerType')372 submit = self.selenium.find_element_by_id('addCustomerID_Submit')373 customerCode_input.send_keys(object_customerCode)374 customerName_input.send_keys(object_customerName)375 procurementName_input.send_keys(object_procurementName)376 procurementWorkNum_input.send_keys(object_procurementWorkNum)377 procurementWorkEmail_input.send_keys(object_procurementEmail)378 technicalName_input.send_keys(object_technicalName)379 technicalWorkNum_input.send_keys(object_technicalWorkNum)380 technicalWorkEmail_input.send_keys(object_technicalWorkEmail)381 customerStatus_input.send_keys(object_customerStatus)382 customerType_input.send_keys(object_customerStatus)383 submit.submit()384 # Information correct?385 self.alert_wait()386 alertObj = self.selenium.switch_to.alert387 alertObj.accept()388 # OK to refresh389 self.alert_wait()390 alertObj = self.selenium.switch_to.alert391 alertObj.accept()392 print("def insert_DeliveryPlan -> complete")393 # Edit an existing CustomerID394 def edit_CustomerID(self, 395 object_searchCustomerInput,396 object_customerCode, 397 object_customerName, 398 object_procurementName, 399 object_procurementWorkNum,400 object_procurementEmail, 401 object_technicalName,402 object_technicalWorkNum, 403 object_technicalWorkEmail,404 object_customerStatus,405 object_customerType):406 # User inserts search information, submits and waits for result407 customerSearch_input = self.selenium.find_element_by_id('searchCustomerIDInput')408 self.selenium.find_element_by_id("searchCustomerID_Submit").submit()409 customerSearch_input.send_keys(object_searchCustomerInput)410 time.sleep(1)411 self.wait_for_(lambda: self.find_object_by_id("customerIDSearchResult_subject", "testCustomerName"))412 self.closeNotifications()413 self.selenium.find_element_by_id('editCustomerID_Toggle').click()414 time.sleep(1)415 customerCode_input = self.selenium.find_element_by_id('Edit_DeliveryPlanForm_customerCode')416 customerName_input = self.selenium.find_element_by_id('Edit_DeliveryPlanForm_customerName')417 procurementName_input = self.selenium.find_element_by_id('Edit_DeliveryPlanForm_procurementName')418 procurementWorkNum_input = self.selenium.find_element_by_id('Edit_DeliveryPlanForm_procurementWorkNum')419 procurementWorkEmail_input = self.selenium.find_element_by_id('Edit_DeliveryPlanForm_procurementWorkEmail')420 technicalName_input = self.selenium.find_element_by_id('Edit_DeliveryPlanForm_technicalName')421 technicalWorkNum_input = self.selenium.find_element_by_id('Edit_DeliveryPlanForm_technicalWorkNum')422 technicalWorkEmail_input = self.selenium.find_element_by_id('Edit_DeliveryPlanForm_technicalWorkEmail')423 customerStatus_input = self.selenium.find_element_by_id('Edit_DeliveryPlanForm_customerStatus')424 customerType_input = self.selenium.find_element_by_id('Edit_DeliveryPlanForm_customerType')425 submit = self.selenium.find_element_by_id('edit_CustomerID_Submit')426 customerCode_input.clear()427 customerName_input.clear()428 procurementName_input.clear()429 procurementWorkNum_input.clear()430 procurementWorkEmail_input.clear()431 technicalName_input.clear()432 technicalWorkNum_input.clear()433 technicalWorkEmail_input.clear()434 customerCode_input.send_keys(object_customerCode)435 customerName_input.send_keys(object_customerName)436 procurementName_input.send_keys(object_procurementName)437 procurementWorkNum_input.send_keys(object_procurementWorkNum)438 procurementWorkEmail_input.send_keys(object_procurementEmail)439 technicalName_input.send_keys(object_technicalName)440 technicalWorkNum_input.send_keys(object_technicalWorkNum)441 technicalWorkEmail_input.send_keys(object_technicalWorkEmail)442 customerStatus_input.send_keys(object_customerStatus)443 customerType_input.send_keys(object_customerStatus)444 submit.submit()445 446 # Information correct?447 self.alert_wait()448 alertObj = self.selenium.switch_to.alert449 alertObj.accept()450 # OK ro refresh451 self.alert_wait()452 alertObj = self.selenium.switch_to.alert453 alertObj.accept() 454 print("def edit_CustomerID -> complete")455 # Insert new Production Meeting456 def insert_DeliveryPlan(self, 457 object_customerID, 458 object_deliveryDate, 459 object_orderPlaced,460 object_invoiceNumber, 461 object_active, 462 object_delayField, 463 object_delayReason):464 465 # User selects form information466 customerID_input = self.selenium.find_element_by_id('DeliveryPlanForm_customerID')467 deliveryDate_input = self.selenium.find_element_by_id('DeliveryPlanForm_dateOfDelivery')468 orderPlacedDate_input = self.selenium.find_element_by_id('DeliveryPlanForm_orderDate')469 invoiceNumber_input = self.selenium.find_element_by_id('DeliveryPlanForm_invoiceNumber')470 active_input = self.selenium.find_element_by_id('DeliveryPlanForm_active')471 delayField_input = self.selenium.find_element_by_id('DeliveryPlanForm_delayField')472 delayReason_input = self.selenium.find_element_by_id('DeliveryPlanForm_delayReason')473 submit = self.selenium.find_element_by_id('addDeliveryPlan_Submit')474 customerID_input.send_keys(object_customerID)475 deliveryDate_input.send_keys(object_deliveryDate)476 orderPlacedDate_input.send_keys(object_orderPlaced)477 invoiceNumber_input.send_keys(object_invoiceNumber)478 active_input.send_keys(object_active)479 delayField_input.send_keys(object_delayField)480 delayReason_input.send_keys(object_delayReason)481 submit.submit()482 # time.sleep(2)483 # Information correct?484 self.alert_wait()485 alertObj = self.selenium.switch_to.alert486 alertObj.accept()487 # OK ro refresh488 self.alert_wait()489 alertObj = self.selenium.switch_to.alert490 alertObj.accept()491 print("def insert_DeliveryPlan -> complete")492 # Insert new raw material shortage493 def insert_RMShortage(self, rmShortage, rmLevel, rmStatus, date=None):494 # User clicks on addProductionNote_Toggle button to toggle form495 print("{}{}".format("addRawMaterial_Toggle:", self.selenium.find_element_by_id('addRawMaterial_Toggle')))496 self.selenium.find_element_by_id('addRawMaterial_Toggle').click()497 # User searches for inputs to name, email and date into input fields and submits information498 rmShortage_input = self.selenium.find_element_by_id('rmShortage_Form_rmShortage')499 rmLevel_input = self.selenium.find_element_by_id('rmShortage_Form_rmLevel')500 rmStatus_input = self.selenium.find_element_by_id('rmShortage_Form_rmStatus')501 # date_input = self.selenium.find_element_by_id('addObject_date')502 submit = self.selenium.find_element_by_id('add_RMShortageForm_Submit')503 rmShortage_input.send_keys(rmShortage)504 rmLevel_input.send_keys(rmLevel)505 rmStatus_input.send_keys(rmStatus)506 # date_input.send_keys(date)507 submit.submit()508 self.alert_wait()509 alertObj = self.selenium.switch_to.alert510 alertObj.accept()511 # Refresh message512 self.alert_wait()513 alertObj = self.selenium.switch_to.alert514 alertObj.accept() 515 print("def insert_RMShortage -> complete")516 # Edit existing raw material shortage517 def edit_RMShortage(self, rmShortage, rmLevel, rmStatus, date=None):518 # User clicks on addProductionNote_Toggle button to toggle form519 print("{}{}".format("addRawMaterial_Toggle:", self.selenium.find_element_by_id('addRawMaterial_Toggle')))520 self.selenium.find_element_by_id('editRawMaterial_Toggle').click()521 # User searches for inputs to name, email and date into input fields and submits information522 rmShortage_input = self.selenium.find_element_by_id('Edit_rmShortage_Form_rmShortage')523 rmLevel_input = self.selenium.find_element_by_id('Edit_rmShortage_Form_rmLevel')524 rmStatus_input = self.selenium.find_element_by_id('Edit_rmShortage_Form_rmStatus')525 # date_input = self.selenium.find_element_by_id('addObject_date')526 submit = self.selenium.find_element_by_id('edit_RMShortageForm_Submit')527 # Clear all fields and insert new Data528 rmLevel_input.clear()529 rmShortage_input.send_keys(rmShortage)530 rmLevel_input.send_keys(rmLevel)531 rmStatus_input.send_keys(rmStatus)532 # date_input.send_keys(date)533 submit.submit()534 self.alert_wait()535 alertObj = self.selenium.switch_to.alert536 alertObj.accept()537 # Refresh message538 self.alert_wait()539 alertObj = self.selenium.switch_to.alert540 alertObj.accept() 541 print("def insert_RMShortage -> complete")542 # Insert new maintenance issue543 def insert_MaintenanceIssue(self, mIssue, mSubject, mStatus, mNote, date=None):544 # User clicks on addProductionNote_Toggle button to toggle form545 print("{}{}".format("addRawMaterial_Toggle:", self.selenium.find_element_by_id('addRawMaterial_Toggle')))546 self.selenium.find_element_by_id('addMaintenanceIssue_Toggle').click()547 # User searches for inputs to name, email and date into input fields and submits information548 mIssue_input = self.selenium.find_element_by_id('maintenanceIssue_Form_maintenanceType')549 mSubject_input = self.selenium.find_element_by_id('maintenanceIssue_Form_subject')550 mStatus_input = self.selenium.find_element_by_id('maintenanceIssue_Form_active')551 mNote_input = self.selenium.find_element_by_id('maintenanceIssue_Form_note')552 # date_input = self.selenium.find_element_by_id('addObject_date')553 submit = self.selenium.find_element_by_id('addMaintenanceIssue_Submit')554 mIssue_input.send_keys(mIssue)555 mSubject_input.send_keys(mSubject)556 mStatus_input.send_keys(mStatus)557 mNote_input.send_keys(mNote)558 # date_input.send_keys(date)559 submit.submit()560 self.alert_wait()561 alertObj = self.selenium.switch_to.alert562 alertObj.accept()563 # Refresh message564 self.alert_wait()565 alertObj = self.selenium.switch_to.alert566 alertObj.accept() 567 # # Refresh production list because refreshObject set to false568 # self.selenium.find_element_by_id('refreshProductionList').click()569 time.sleep(2)570 print("def insert_MaintenanceIssue -> complete")571 # Insert new maintenance issue572 def edit_MaintenanceIssue(self, mIssue, mSubject, mStatus, mNote, date=None):573 # User clicks on addProductionNote_Toggle button to toggle form574 self.selenium.find_element_by_id('editMaintenanceIssue_Toggle').click()575 # User searches for inputs to name, email and date into input fields and submits information576 mIssue_input = self.selenium.find_element_by_id('Edit_maintenanceIssue_Form_maintenanceType')577 mSubject_input = self.selenium.find_element_by_id('Edit_maintenanceIssue_Form_subject')578 mStatus_input = self.selenium.find_element_by_id('Edit_maintenanceIssue_Form_active')579 mNote_input = self.selenium.find_element_by_id('Edit_maintenanceIssue_Form_note')580 # date_input = self.selenium.find_element_by_id('addObject_date')581 submit = self.selenium.find_element_by_id('edit_MaintenanceIssue_Submit')582 # Clear all fields and insert new Data583 mSubject_input.clear()584 mNote_input.clear()585 mIssue_input.send_keys(mIssue)586 mSubject_input.send_keys(mSubject)587 mStatus_input.send_keys(mStatus)588 mNote_input.send_keys(mNote)589 # date_input.send_keys(date)590 submit.submit()591 # Information correct?592 self.alert_wait()593 alertObj = self.selenium.switch_to.alert594 alertObj.accept()595 # Refresh message596 self.alert_wait()597 alertObj = self.selenium.switch_to.alert598 alertObj.accept() 599 # # Refresh production list because refreshObject set to false600 # self.selenium.find_element_by_id('refreshProductionList').click()601 time.sleep(2)602 print("def insert_MaintenanceIssue -> complete")603 # Insert new production plan604 def insert_ProductionPlan(self, pPlan_machine, pPlan_BN, pPlan_description, pPlan_status, date=None):605 # User clicks on addProductionNote_Toggle button to toggle form606 print("{}{}".format("addProductionPlan_Toggle:", self.selenium.find_element_by_id('addProductionPlan_Toggle')))607 self.selenium.find_element_by_id('addProductionPlan_Toggle').click()608 # User searches for inputs to name, email and date into input fields and submits information609 pPlan_machine_input = self.selenium.find_element_by_id('ProductionPlan_Form_machine')610 pPlan_BN_input = self.selenium.find_element_by_id('ProductionPlan_Form_batchNumber')611 pPlan_description_input = self.selenium.find_element_by_id('ProductionPlan_Form_productDescription')612 pPlan_status_input = self.selenium.find_element_by_id('ProductionPlan_Form_status')613 # date_input = self.selenium.find_element_by_id('addObject_date')614 submit = self.selenium.find_element_by_id('addProductionPlan_Submit')615 pPlan_machine_input.send_keys(pPlan_machine)616 pPlan_BN_input.send_keys(pPlan_BN)617 pPlan_description_input.send_keys(pPlan_description)618 pPlan_status_input.send_keys(pPlan_status)619 # date_input.send_keys(date)620 submit.submit()621 # Information correct?622 self.alert_wait()623 alertObj = self.selenium.switch_to.alert624 alertObj.accept()625 # Refresh message626 self.alert_wait()627 alertObj = self.selenium.switch_to.alert628 alertObj.accept() 629 # # Refresh production list because refreshObject set to false630 # self.selenium.find_element_by_id('refreshProductionList').click()631 time.sleep(2)632 print("def insert_MaintenanceIssue -> complete")633 # edit existing production plan634 def edit_ProductionPlan(self, pPlan_machine, pPlan_BN, pPlan_description, pPlan_status, date=None):635 # User clicks on addProductionNote_Toggle button to toggle form636 self.selenium.find_element_by_id('editProductionPlan_Toggle').click()637 # User searches for inputs to name, email and date into input fields and submits information638 pPlan_machine_input = self.selenium.find_element_by_id('Edit_ProductionPlan_Form_machine')639 pPlan_BN_input = self.selenium.find_element_by_id('Edit_ProductionPlan_Form_batchNumber')640 pPlan_description_input = self.selenium.find_element_by_id('Edit_ProductionPlan_Form_productDescription')641 pPlan_status_input = self.selenium.find_element_by_id('Edit_ProductionPlan_Form_status')642 # date_input = self.selenium.find_element_by_id('addObject_date')643 submit = self.selenium.find_element_by_id('edit_ProductionPlan_Submit')644 # Clear all fields and insert new Data645 pPlan_description_input.clear()646 pPlan_machine_input.send_keys(pPlan_machine)647 pPlan_BN_input.send_keys(pPlan_BN)648 pPlan_description_input.send_keys(pPlan_description)649 pPlan_status_input.send_keys(pPlan_status)650 # date_input.send_keys(date)651 submit.submit()652 # Information correct?653 self.alert_wait()654 alertObj = self.selenium.switch_to.alert655 alertObj.accept()656 # Refresh message657 self.alert_wait()658 alertObj = self.selenium.switch_to.alert659 alertObj.accept() 660 # # Refresh production list because refreshObject set to false661 # self.selenium.find_element_by_id('refreshProductionList').click()662 time.sleep(2)663 print("def insert_MaintenanceIssue -> complete")664# Insert new production plan665 def insert_ProductType(self, productCode, productDescription, date=None):666 # User inserts product code and description667 productCode_input = self.selenium.find_element_by_id('ProductTypeForm_productCode')668 productDescription_input = self.selenium.find_element_by_id('ProductTypeForm_productDescription')669 # User types data and submits670 submit = self.selenium.find_element_by_id('addProductTypeForm_Submit')671 productCode_input.send_keys(productCode)672 productDescription_input.send_keys(productDescription)673 submit.submit()674 # Information correct?675 self.alert_wait()676 alertObj = self.selenium.switch_to.alert677 alertObj.accept()678 # Success message679 self.alert_wait()680 alertObj = self.selenium.switch_to.alert681 alertObj.accept()682 time.sleep(2)683 print("def insert_ProductType -> complete")684# Insert new production plan685 def insert_Batch(self, paintInfoType, rdProject, productType, batchPeriod, batchNumber, date=None):686 # User inserts product code and description687 paintInfo_input = self.selenium.find_element_by_id('PaintInfoForm_paintInfoType')688 rdProject_input = self.selenium.find_element_by_id('PaintInfoForm_rdProject')689 productType_input = self.selenium.find_element_by_id('PaintInfoForm_productType')690 batchPeriod_input = self.selenium.find_element_by_id('PaintInfoForm_batchPeriod')691 batchNumber_input = self.selenium.find_element_by_id('PaintInfoForm_batchNumber')692 batch_input = self.selenium.find_element_by_id('ProductTypeForm_productDescription')693 # User types data and submits694 submit = self.selenium.find_element_by_id('addBatch_Submit')695 paintInfo_input.send_keys(paintInfoType)696 rdProject_input.send_keys(rdProject)697 productType_input.send_keys(productType)698 batchPeriod_input.send_keys(batchPeriod)699 batchNumber_input.send_keys(batchNumber)700 submit.submit()701 # Information correct?702 self.alert_wait()703 alertObj = self.selenium.switch_to.alert704 alertObj.accept()705 # Success message706 self.alert_wait()707 alertObj = self.selenium.switch_to.alert708 alertObj.accept()709 time.sleep(2)710 print("def insert_Batch -> complete")711# Insert premix information712 def insert_premixInfo(self, premixDateIssued, premixInitialFog, premixInitialVisc, premixInitialViscUnit, premixDateLoaded, premixDatePremixPassed, premixFinalFOG, date=None):713 # User inserts product code and description714 premixDateIssued_input = self.selenium.find_element_by_id('Edit_PaintInfoForm_dateIssued')715 premixInitialFog_input = self.selenium.find_element_by_id('Edit_PaintInfoForm_initialFog')716 premixInitialVisc_input = self.selenium.find_element_by_id('Edit_PaintInfoForm_initialViscosity')717 premixInitialViscUnit_input = self.selenium.find_element_by_id('Edit_PaintInfoForm_initialViscosityUnit')718 premixDatePremixLoaded_input = self.selenium.find_element_by_id('Edit_PaintInfoForm_dateLoaded')719 premixDatePremixPassed_input = self.selenium.find_element_by_id('Edit_PaintInfoForm_datePremixPassed')720 premixFinalFOG_input = self.selenium.find_element_by_id('Edit_PaintInfoForm_finalFog')721 batch_input = self.selenium.find_element_by_id('ProductTypeForm_productDescription')722 # User types data and submits723 submit = self.selenium.find_element_by_id('addPremixInfo_Submit')724 premixDateIssued_input.send_keys(premixDateIssued)725 premixInitialFog_input.send_keys(premixInitialFog)726 premixInitialVisc_input.send_keys(premixInitialVisc)727 premixInitialViscUnit_input.send_keys(premixInitialViscUnit)728 premixDatePremixLoaded_input.send_keys(premixDateLoaded)729 premixDatePremixPassed_input.send_keys(premixDatePremixPassed)730 premixFinalFOG_input.send_keys(premixFinalFOG)731 submit.submit()732 # Information correct?733 self.alert_wait()734 alertObj = self.selenium.switch_to.alert735 alertObj.accept()736 # Server success737 self.alert_wait()738 alertObj = self.selenium.switch_to.alert739 alertObj.accept()740 time.sleep(2)741 print("def insert_premixInfo -> complete")742# Insert new production plan743 def insert_BatchInfo(self, finalSg, finalOpacity, finalGloss, finalTouchDry, finalTouchDryUnit, finalHardDry, finalHardDryUnit, finalDFT, finalDFTUnit, finalViscosity, finalViscosityUnit, finalColorDe, finalColorDeSpec, date=None):744 print("finalSg: {}".format(finalSg))745 # User identifies fields746 finalSg_input = self.selenium.find_element_by_id('Edit_BatchInfoForm_finalSg')747 finalOpacity_input = self.selenium.find_element_by_id('Edit_BatchInfoForm_finalOpacity')748 finalGloss_input = self.selenium.find_element_by_id('Edit_BatchInfoForm_finalGloss')749 finalTouchDry_input = self.selenium.find_element_by_id('Edit_BatchInfoForm_finalTouchDry')750 finalTouchDryUnit_input = self.selenium.find_element_by_id('Edit_BatchInfoForm_finalTouchDryUnit')751 finalHardDry_input = self.selenium.find_element_by_id('Edit_BatchInfoForm_finalHardDry')752 finalHardDryUnit_input = self.selenium.find_element_by_id('Edit_BatchInfoForm_finalHardDryUnit')753 finalDFT_input = self.selenium.find_element_by_id('Edit_BatchInfoForm_finalDft')754 finalDFTUnit_input = self.selenium.find_element_by_id('Edit_BatchInfoForm_finalDftUnit')755 finalViscosity_input = self.selenium.find_element_by_id('Edit_BatchInfoForm_finalViscosity')756 finalViscosityUnit_input = self.selenium.find_element_by_id('Edit_BatchInfoForm_finalViscosityUnit')757 finalColorDe_input = self.selenium.find_element_by_id('Edit_BatchInfoForm_finalColorDe')758 finalColorDeSpec_input = self.selenium.find_element_by_id('Edit_BatchInfoForm_finalColorDeSpec')759 submit = self.selenium.find_element_by_id('addBatchInfo_Submit')760 # User types data and submits761 finalSg_input.send_keys(finalSg)762 finalOpacity_input.send_keys(finalOpacity)763 finalGloss_input.send_keys(finalGloss)764 finalTouchDry_input.send_keys(finalTouchDry)765 finalTouchDryUnit_input.send_keys(finalTouchDryUnit)766 finalHardDry_input.send_keys(finalHardDry)767 finalHardDryUnit_input.send_keys(finalHardDryUnit)768 finalDFT_input.send_keys(finalDFT)769 finalDFTUnit_input.send_keys(finalDFTUnit)770 finalViscosity_input.send_keys(finalViscosity)771 finalViscosityUnit_input.send_keys(finalViscosityUnit)772 finalColorDe_input.send_keys(finalColorDe)773 finalColorDeSpec_input.send_keys(finalColorDeSpec)774 775 submit.submit()776 # Information correct?777 self.alert_wait()778 alertObj = self.selenium.switch_to.alert779 alertObj.accept()780 # Success message781 self.alert_wait()782 alertObj = self.selenium.switch_to.alert783 alertObj.accept()784 time.sleep(5)785 print("def insert_BatchInfo -> complete")786# Insert new production plan787 def insert_BatchAdjustment(self, rm, adjustAmount, adjustmentUnit):788 # User identifies fields789 rm_input = self.selenium.find_element_by_id('BatchAdjustmentForm_rmCode')790 adjustAmount_input = self.selenium.find_element_by_id('BatchAdjustmentForm_adjustmentAmount')791 adjustmentUnit_input = self.selenium.find_element_by_id('BatchAdjustmentForm_adjustmentUnit')792 submit = self.selenium.find_element_by_id('addFinishingAdjustment_Submit')793 # User types data and submits794 rm_input.send_keys(rm)795 adjustAmount_input.send_keys(adjustAmount)796 adjustmentUnit_input.send_keys(adjustmentUnit)797 798 submit.submit()799 # Information correct?800 self.alert_wait()801 alertObj = self.selenium.switch_to.alert802 alertObj.accept()803 # Success message804 self.alert_wait()805 alertObj = self.selenium.switch_to.alert806 alertObj.accept()807 time.sleep(5)808 print("def insert_BatchAdjustment -> complete")809# Edit batch adjustment810 def edit_BatchAdjustment(self, adjustAmount, adjustmentUnit):811 # User identifies fields812 # rm_input = self.selenium.find_element_by_id('Edit_BatchAdjustmentForm_rmCode')813 adjustAmount_input = self.selenium.find_element_by_id('Edit_BatchAdjustmentForm_adjustmentAmount')814 adjustmentUnit_input = self.selenium.find_element_by_id('Edit_BatchAdjustmentForm_adjustmentUnit')815 submit = self.selenium.find_element_by_id('addBatchAdjustment_Submit')816 # User clears old fields types data and submits817 adjustAmount_input.clear()818 adjustAmount_input.send_keys(adjustAmount)819 adjustmentUnit_input.send_keys(adjustmentUnit)820 821 submit.submit()822 # Information correct?823 self.alert_wait()824 alertObj = self.selenium.switch_to.alert825 alertObj.accept()826 # refresh827 self.alert_wait()828 alertObj = self.selenium.switch_to.alert829 alertObj.accept()830 time.sleep(5)831 print("def edit_BatchAdjustment -> complete")832# Edit RD Project833 def edit_RDProject(self, customer, subject, instructions):834 # User identifies fields835 customer_input = self.selenium.find_element_by_id('Edit_RDProject_customer')836 subject_input = self.selenium.find_element_by_id('Edit_RDProject_subject')837 instructions_input = self.selenium.find_element_by_id('Edit_RDProject_instructions')838 submit = self.selenium.find_element_by_id('editRDProject_Submit')839 # User clears old fields types data and submits840 customer_input.send_keys(customer)841 subject_input.send_keys(subject)842 instructions_input.send_keys(instructions)843 submit.submit()844 # Information correct?845 self.alert_wait()846 alertObj = self.selenium.switch_to.alert847 alertObj.accept()848 # refresh849 self.alert_wait()850 alertObj = self.selenium.switch_to.alert851 alertObj.accept()852 time.sleep(5)853 print("def edit_RDProject -> complete")854# Edit RD Project855 def edit_ProductType(self, productCode, productDescription):856 # User identifies fields857 productCode_input = self.selenium.find_element_by_id('Edit_ProductType_productCode')858 productDescription_input = self.selenium.find_element_by_id('Edit_ProductType_productDescription')859 submit = self.selenium.find_element_by_id('editProductType_Submit')860 # User clears old fields types data and submits861 productCode_input.clear()862 productDescription_input.clear()863 productCode_input.send_keys(productCode)864 productDescription_input.send_keys(productDescription)865 submit.submit()866 # Information correct?867 self.alert_wait()868 alertObj = self.selenium.switch_to.alert869 alertObj.accept()870 # refresh871 self.alert_wait()872 alertObj = self.selenium.switch_to.alert873 alertObj.accept()874 time.sleep(5)...

Full Screen

Full Screen

CustomDriver.py

Source:CustomDriver.py Github

copy

Full Screen

1from appium import webdriver2from selenium.webdriver.support.ui import WebDriverWait3from selenium.webdriver.support import expected_conditions as EC4from selenium.common.exceptions import TimeoutException5from selenium.webdriver.common.by import By6from config_entries.Properties import Properties7from appium.webdriver.common.touch_action import TouchAction8__author__ = 'andrey'9class CustomDriver(webdriver.Remote):10 def __init__(self):11 self.driver = None12 """:type: appium.webdriver.Remote"""13 self.driver_wait = None14 """:type: selenium.webdriver.support.ui.WebDriverWait"""15 self.alert_wait = None16 self.session_id = None17 def long_press_to_element_and_move_to_other_element(self, from_element, to_element, time_in_seconds):18 touch_action = TouchAction(self.driver)19 touch_action.long_press(from_element).wait(time_in_seconds * 1000).move_to(to_element).wait(20 1000).release().perform()21 def long_press_on_element(self, element, time_in_seconds):22 touch_action = TouchAction(self.driver)23 touch_action.long_press(element).wait(time_in_seconds * 1000)24 touch_action.perform()25 def swipe(self, start_x, start_y, end_x, end_y, duration=1000):26 self.driver.swipe(start_x, start_y, end_x, end_y, duration)27 def swipe_up(self, x, y, distance):28 self.swipe(x, y, x, y + distance)29 def swipe_down(self, x, y, distance):30 self.swipe(x, y, x, y - distance)31 def swipe_left(self, x, y, distance):32 self.swipe(x, y, x - distance, y)33 def swipe_right(self, x, y, distance):34 self.swipe(x, y, x + distance, y)35 def find_element_by_xpath(self, xpath):36 # if self.driver_wait.until(EC.presence_of_element_located((By.XPATH, xpath))):37 # return self.driver.find_element_by_xpath(xpath)38 return self.driver_wait.until(EC.presence_of_element_located((By.XPATH, xpath)))39 def find_element_by_name(self, name):40 # if self.driver_wait.until(EC.presence_of_element_located((By.NAME, name))):41 # return self.driver.find_element_by_name(name)42 return self.driver_wait.until(EC.presence_of_element_located((By.NAME, name)))43 def find_elements_by_xpath(self, xpath):44 if self.driver_wait.until(EC.presence_of_all_elements_located((By.XPATH, xpath))):45 return self.driver.find_elements_by_xpath(xpath)46 def put_app_in_background(self, time_idle):47 self.driver.background_app(time_idle)48 def setup(self, desired_caps, driver_wait_time=30, alert_wait_time=15):49 self.driver = webdriver.Remote(Properties.get_external_parameters().get_remote_server_url(), desired_caps)50 self.driver_wait = WebDriverWait(self.driver, driver_wait_time)51 self.alert_wait = WebDriverWait(self.driver, alert_wait_time)52 def is_alert_present(self):53 try:54 self.alert_wait.until(EC.alert_is_present())55 return True56 except RuntimeError:57 return False58 def get_alert(self):59 alert = None60 if self.is_alert_present():61 alert = self.driver.switch_to.alert()62 return alert63 def get_alert_text(self):64 alert = self.get_alert()65 if alert is not None:66 return alert.text67 return ''68 def alert_accept(self):69 alert = self.get_alert()70 if alert is not None:71 alert.accept()72 def alert_decline(self):73 alert = self.get_alert()74 if alert is not None:75 alert.decline()76 def is_element_presented(self, locator, by=By.XPATH, wait_seconds=15):77 try:78 availability_wait = WebDriverWait(self.driver, wait_seconds)79 availability_wait.until(EC.presence_of_element_located((by, locator)))80 return True81 except TimeoutException:82 return False83 def is_element_visible(self, locator, by=By.XPATH, wait_seconds=15):84 try:85 availability_wait = WebDriverWait(self.driver, wait_seconds)86 availability_wait.until(EC.visibility_of_element_located((by, locator)))87 return True88 except TimeoutException:89 return False90 def is_element_clickable(self, locator, by=By.XPATH, wait_seconds=15):91 try:92 availability_wait = WebDriverWait(self.driver, wait_seconds)93 availability_wait.until(EC.element_to_be_clickable((by, locator)))94 return True95 except TimeoutException:96 return False97 def back(self):98 self.driver.back()99 def keyevent(self, keycode, metastate=None):100 return self.driver.keyevent(keycode, metastate)101 def tap(self, positions, duration=None):102 return self.driver.tap(positions, duration)103 def quit(self):104 if self.driver is not None:105 self.driver.quit()106 def take_screenshot(self, file_name):...

Full Screen

Full Screen

handlers.py

Source:handlers.py Github

copy

Full Screen

1from django.conf import settings2from django.dispatch import receiver3from howl.models import Alert4from howl.signals import alert_clear, alert_notify, alert_wait5from .pushover import PushoverApi6def notify(level, instance, signal=None, **kwargs):7 if 'observer' in kwargs:8 title = '{0}: {1}'.format(level.upper(), kwargs['observer'].name)9 else:10 title = kwargs.pop('title', instance)11 api = PushoverApi(settings.PUSHOVER_TOKEN)12 api.send_notification(13 settings.PUSHOVER_RECIPIENT, title, level, alert=instance, **kwargs)14@receiver(alert_wait, sender=Alert)15def send_warning(sender, instance, **kwargs):16 notify('warning', instance, **kwargs)17@receiver(alert_notify, sender=Alert)18def send_alert(sender, instance, **kwargs):19 notify('critical', instance, **kwargs)20@receiver(alert_clear, sender=Alert)21def send_clear(sender, instance, **kwargs):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful