def update_item_price( target_agreement, item_id, item_price, ): browser.get( 'https://sysco.sprocketcmms.com/Default.aspx?screen=Vendor%20Purchase%20Agreements' ) parent_vpa = browser.find_element_by_link_text(target_agreement) parent_vpa.click() items_tab = browser.find_element_by_id('liItems') items_tab.click() search_id = browser.find_element_by_id( 'ajaxReport_itemsReport_promptsdivContainer_0_input') search_id.clear() search_id.send_keys(item_id) id_search_button = browser.find_element_by_xpath( '/html/body/form/div[3]/div[3]/div[2]/div/div[2]/div/div[1]/input') id_search_button.click() time.sleep(1) get_edit = browser.find_element_by_link_text('Edit') get_edit.click() price_field = browser.find_element_by_id('StdSf581_Price_txt') price_field.clear() price_field.send_keys(item_price) save_button = browser.find_element_by_xpath( '/html/body/form/div[3]/div[3]/div[3]/div[3]/input[1]') save_button.click() time.sleep(1) print('VPA {} item {} price updated to {}'.format(target_agreement, item_id, item_price))
def fsi_page_three(sch_name, start, frequency, day_dropdown='Daily', set=0, week_day=0): set_lead_days = ['0', '7', '30'] pm_plan_link = browser.find_element_by_link_text('Add a new PM Project Plan Schedule') pm_plan_link.click() time.sleep(1) name_page3 = browser.find_element_by_id('schedule_txtName') name_page3.send_keys(sch_name) start_page3 = browser.find_element_by_id('schedule_txtStartDate') start_page3.send_keys(start) lead_days = browser.find_element_by_id('schedule_txtLeadDays') lead_days.send_keys(set_lead_days[set]) daily3 = Select(browser.find_element_by_id('ddlRecurrenceType')) daily3.select_by_visible_text(day_dropdown) # week_day 1=Daily 2=Weekly 3=Monthly if week_day == 1: browser.find_element_by_id('dr_chkEveryWeekday').click() save_sch3 = browser.find_element_by_xpath('//*[@id="tblPMProjectPlanSchedule"]/table/tbody/tr[2]/td[2]/input') time.sleep(1) save_sch3.click() time.sleep(1) next3 = browser.find_element_by_id('btn_Step3_Next') time.sleep(1) next3.click() time.sleep(1) elif week_day == 2: browser.find_element_by_id('weekR_txtEvery').send_keys(frequency) browser.find_element_by_id('weekR_sunday').click() save_sch3 = browser.find_element_by_xpath('//*[@id="tblPMProjectPlanSchedule"]/table/tbody/tr[2]/td[2]/input') time.sleep(1) save_sch3.click() time.sleep(1) next3 = browser.find_element_by_id('btn_Step3_Next') time.sleep(1) next3.click() time.sleep(1) elif week_day == 3: browser.find_element_by_id('monthR_XOfEveryMonths').click() browser.find_element_by_id('monthR_XInstanceMonth').send_keys(frequency) save_sch3 = browser.find_element_by_xpath('//*[@id="tblPMProjectPlanSchedule"]/table/tbody/tr[2]/td[2]/input') time.sleep(1) save_sch3.click() time.sleep(1) next3 = browser.find_element_by_id('btn_Step3_Next') time.sleep(1) next3.click() time.sleep(1) else: target_frequency = browser.find_element_by_id('dailyR_txtEvery') target_frequency.send_keys(frequency) save_sch3 = browser.find_element_by_xpath('//*[@id="tblPMProjectPlanSchedule"]/table/tbody/tr[2]/td[2]/input') time.sleep(1) save_sch3.click() time.sleep(1) next3 = browser.find_element_by_id('btn_Step3_Next') time.sleep(1) next3.click() time.sleep(1)
def add_safety(target_user, a): browser.implicitly_wait(10) browser.get( 'https://sysco.sprocketcmms.com/Default.aspx?screen=People&SSF=-134') search_box = browser.find_element_by_link_text('Search') search_box.click() user_name_field = browser.find_element_by_id('UserName_txt0') user_name_field.clear() user_name_field.send_keys(target_user) start_search = browser.find_element_by_id('SearchScreenBtnSearch') start_search.click() browser.find_element_by_link_text(target_user).click() time.sleep(3) if int(a) == 1: print('Flagging OverrideWorkDay') ignore_wdt = browser.find_element_by_id('StdSf_62_OverrideWorkDay_chk') ignore_wdt.click() groups_tab = browser.find_element_by_id('liGroups') time.sleep(3) groups_tab.click() add_group = browser.find_element_by_id('txt_Group') add_group.send_keys('Data-FSY') submit_group = browser.find_element_by_xpath( '//*[@id="divGroups"]/table/tbody/tr[1]/td[2]/input[2]') submit_group.click() time.sleep(1) save_exit = browser.find_element_by_link_text('Save') save_exit.click() time.sleep(3) browser.switch_to.alert.accept()
def user_details(target_id, first_name, last_name, a=1): browser.get( 'https://sysco.sprocketcmms.com/Default.aspx?screen=People&SSF=-134') create_new_person_button = browser.find_element_by_xpath( '//*[@id="btnNewLink"]') create_new_person_button.click() time.sleep(3) id_field = browser.find_element_by_id('StdSf_62_UserName_txt') id_field.clear() id_field.send_keys(target_id) fname_field = browser.find_element_by_id('StdSf_62_FirstName_txt') fname_field.clear() fname_field.send_keys(first_name) lname_field = browser.find_element_by_id('StdSf_62_LastName_txt') lname_field.clear() lname_field.send_keys(last_name) ignore_wdt = browser.find_element_by_id('StdSf_62_OverrideWorkDay_chk') ignore_wdt.click() ignore_wd_termination = browser.find_element_by_id( 'StdSf_62_IgnoreWorkDayTermination_chk') ignore_wd_termination.click() access_flag = int(a) if access_flag == 1: access_food_safety = browser.find_element_by_id( 'StdSf_62_Food_Safety_chk') access_food_safety.click() save_initial = browser.find_element_by_id('liSave') save_initial.click() time.sleep(5) browser.switch_to.alert.accept() time.sleep(1)
def empty_sch(): # Create Empty Sch empty_sch_tab = browser.find_element_by_id('liSchedules') empty_sch_tab.click() time.sleep(1) browser.find_element_by_id('AddNewProjectPlanLink').click() browser.find_element_by_id('schedule_txtName').clear() browser.find_element_by_id('schedule_txtName').send_keys('Test Update') browser.find_element_by_id('schedule_txtStartDate').send_keys('01012099') daily3 = Select(browser.find_element_by_id('ddlRecurrenceType')) daily3.select_by_visible_text('Does not repeat') lead_days = browser.find_element_by_id('schedule_txtLeadDays') lead_days.clear() lead_days.send_keys('0') empty_save_sch = save_sch3 = browser.find_element_by_xpath( '/html/body/form/div[3]/div[3]/div[5]/div[1]/table/tbody/tr[5]/td[2]/input' ) empty_save_sch.click() time.sleep(1) # Use Empty Request empty_req_tab = browser.find_element_by_id('liRequests') empty_req_tab.click() time.sleep(1) browser.find_element_by_id('txtRequestName').send_keys('testing') empty_add = browser.find_element_by_id('lnkAddRequest') empty_add.click() time.sleep(1) save_details = browser.find_element_by_link_text('Save') save_details.click() return_to_details = browser.find_element_by_id('liInformation') return_to_details.click() time.sleep(1)
def create_vpa(y, y_description, y_vendor_id, y_date, y_expire, PreferredVendor=1): browser.get('https://sysco.sprocketcmms.com/Default.aspx?screen=Vendor%20Purchase%20Agreements') vpa_new_button = browser.find_element_by_xpath('//*[@id="btnNewLink"]') time.sleep(1) vpa_new_button.click() name_field = browser.find_element_by_id('StdSf580_Name_txt') name_field.send_keys(y) description_field = browser.find_element_by_id('StdSf580_Description_txt') description_field.send_keys(y_description) vendor_id_field = browser.find_element_by_id('StdSf580_VendorID_txt') vendor_id_field.send_keys(y_vendor_id) start_date_field = browser.find_element_by_id('StdSf580_StartDate_txt') start_date_field.send_keys(y_date) end_date_field = browser.find_element_by_id('StdSf580_EndDate_txt') end_date_field.send_keys(y_expire) preferred_vendor_check = browser.find_element_by_id('StdSf580_PreferredVendor_chk') if PreferredVendor == 1: preferred_vendor_check.click() time.sleep(1) browser.find_element_by_link_text('Save').click() time.sleep(1) browser.find_element_by_link_text('Exit').click() else: browser.find_element_by_link_text('Save').click() time.sleep(1) browser.find_element_by_link_text('Exit').click()
def remove_web_group(): browser.implicitly_wait(10) group_tab = browser.find_element_by_id('liGroups') group_tab.click() time.sleep(3) web_group = browser.find_element_by_xpath( '//*[@id="groups_AssignedGroups"]/option[2]') web_group.click() remove_button = browser.find_element_by_xpath( '//*[@id="divGroups"]/table/tbody/tr[2]/td[2]/input') remove_button.click() time.sleep(3) save_groups = browser.find_element_by_link_text('Save') save_groups.click() time.sleep(5) browser.switch_to.alert.accept() time.sleep(1)
def gen_number(unit_description, location, equipment_type, department, manufacturer, inventory_number, start_date, gb_fuel_type, equipment_system): browser.get( 'https://sysco.sprocketcmms.com/Default.aspx?screen=Equipment&SSF=-102' ) time.sleep(1) new_equip_button = browser.find_element_by_id('btnNewLink') new_equip_button.click() field_id = browser.find_element_by_id('StdSf_70_EquipmentIdentifier_txt') field_id.send_keys('AUTONUMBER') desc_field = browser.find_element_by_id('StdSf_70_Description_txt') desc_field.send_keys(unit_description) location_field = browser.find_element_by_id('StdSf_70_LocationID_txt') location_field.send_keys(location) type_field = browser.find_element_by_id('StdSf_70_EquipmentTypeID_txt') type_field.send_keys(equipment_type) dept_field = browser.find_element_by_xpath( '//*[@id="StdSf_70_Div1"]/p[8]/div/input') dept_field.send_keys(department) man_field = browser.find_element_by_id('StdSf_70_Manufacturer_txt') man_field.send_keys(manufacturer) inv_field = browser.find_element_by_id('StdSf_70_InventoryNumber_txt') inv_field.send_keys(inventory_number) start_date_field = browser.find_element_by_id('StdSf_70_DateInService_txt') start_date_field.send_keys(start_date) gb_type_field = browser.find_element_by_xpath( '//*[@id="StdSf_70_Div3"]/p[12]/div/input') gb_type_field.send_keys(gb_fuel_type) equip_sys_field = browser.find_element_by_id( 'StdSf_70_EquipmentSystemID_txt') equip_sys_field.send_keys(equipment_system) browser.find_element_by_link_text('Save').click() time.sleep(3)
def flip_clone(new_name): edit_clone = browser.find_element_by_xpath('//*[@id="ctl00_MainPage_Search2_resultsGrid_ctl00__0"]/td[7]/a') edit_clone.click() pyautogui.moveTo(537, 250, duration=1) pyautogui.rightClick() pyautogui.moveTo(538, 251, duration=1) pyautogui.leftClick() time.sleep(1) clone_name = browser.find_element_by_xpath('/html/body/form/div[7]/div[2]/div/table/tbody/tr[2]/td[2]/input') clone_name.clear() clone_name.send_keys(new_name) clone_description = browser.find_element_by_xpath('/html/body/form/div[7]/div[2]/div/table/tbody/tr[3]/td[2]/input') clone_description.clear() clone_description.send_keys(new_name) save_clone_update = browser.find_element_by_xpath('/html/body/form/div[7]/div[2]/div/table/tbody/tr[5]/td[2]/input') save_clone_update.click()
def add_user_group(group): groups_tab = browser.find_element_by_id('liGroups') groups_tab.click() time.sleep(3) add_group = browser.find_element_by_id('txt_Group') add_group.send_keys(group) submit_group = browser.find_element_by_xpath( '//*[@id="divGroups"]/table/tbody/tr[1]/td[2]/input[2]') submit_group.click() time.sleep(3)
def page_three_alt(sch_name, start, set=0): set_lead_days = ['0', '7', '30'] pm_plan_link = browser.find_element_by_link_text( 'Add a new PM Project Plan Schedule') pm_plan_link.click() time.sleep(1) name_page3 = browser.find_element_by_id('schedule_txtName') name_page3.send_keys(sch_name) start_page3 = browser.find_element_by_id('schedule_txtStartDate') start_page3.send_keys(start) lead_days = browser.find_element_by_id('schedule_txtLeadDays') lead_days.clear() lead_days.send_keys(set_lead_days[set]) daily3 = Select(browser.find_element_by_id('ddlRecurrenceType')) daily3.select_by_visible_text('Does not repeat') save_sch3 = browser.find_element_by_xpath( '//*[@id="tblPMProjectPlanSchedule"]/table/tbody/tr[2]/td[2]/input') time.sleep(1) save_sch3.click() time.sleep(1) next3 = browser.find_element_by_id('btn_Step3_Next') time.sleep(1) next3.click() time.sleep(1)
def clone_main(): time.sleep(1) clone_it = browser.find_element_by_xpath('//*[@id="ctl00_MainPage_Search2_resultsGrid_ctl00__0"]/td[11]/a') clone_it.click() print('Inspection cloned') time.sleep(1)
while x <= counter: try: x += 1 if sch_type == 0: browser.get( 'https://sysco.sprocketcmms.com/Default.aspx?screen=PM%20Projects&SSF=-108' ) else: browser.get( 'https://sysco.sprocketcmms.com/Default.aspx?screen=PM%20Projects&SSF=244' ) search_trigger = browser.find_element_by_id('liSearch').click() search_box = browser.find_element_by_id('PMNumber_txt3') search_box.clear() search_box.send_keys(unit[x]) search_button = browser.find_element_by_id('SearchScreenBtnSearch') search_button.click() time.sleep(5) archive_link = browser.find_element_by_xpath( '//*[@id="ctl00_MainPage_Search2_resultsGrid_ctl00__0"]/td[11]/a') archive_link.click() except IndexError: print('Script Complete!') break except Exception as b: print('Error----->\n{}'.format(b)) continue browser.quit()
# Attach option to Model browser.find_element_by_id('liSearch').click() model_search = browser.find_element_by_id('Name_txt0') model_search.clear() model_search.send_keys(model[x]) browser.find_element_by_id('SearchScreenBtnSearch').click() time.sleep(1) browser.find_element_by_link_text(model[x]).click() time.sleep(1) browser.find_element_by_link_text('Options').click() tree1 = '//*[@id="ctl00_MainPage_EquipmentBuilder_OptionsTree"]/ul/li/div/span[2]' # tree1 = '//div[@id='ctl00_MainPage_EquipmentBuilder_OptionsTree']/ul/li/div/div/div/div/input' tree2 = '//*[@id="ctl00_MainPage_EquipmentBuilder_OptionsTree"]/ul/li/div/div/div/div/input' holdChild = browser.find_element_by_xpath(tree1) addChild = browser.find_element_by_xpath(tree2) # Mouse over and click hidden element holdChild.click() action = ActionChains(browser) action.move_to_element(holdChild).click().perform() browser.execute_script("arguments[0].click();", addChild) # Attach Option # browser.switch_to.active_element() select1 = Select(browser.find_element_by_xpath('//*[@id="ObjectTableName"]')) select1.select_by_visible_text('Equipment Option') # findOPtion = browser.find_element_by_xpath('//*[@id="ObjectID_magnifier"]').click() chooseOption = browser.find_element_by_xpath('//*[@id="ObjectID"]') chooseOption.send_keys(name)
# Populate Form field_id = browser.find_element_by_id( 'StdSf_70_EquipmentIdentifier_txt') #field_id.clear() field_id.send_keys(target_number[x]) desc_field = browser.find_element_by_id('StdSf_70_Description_txt') #desc_field.clear() desc_field.send_keys(unit_descrip[x]) loc_field = browser.find_element_by_id('StdSf_70_LocationID_txt') #loc_field.clear() loc_field.send_keys(location[x]) type_field = browser.find_element_by_id('StdSf_70_EquipmentTypeID_txt') #type_field.clear() type_field.send_keys(equip_type[x]) dept_field = browser.find_element_by_xpath( '//*[@id="StdSf_70_Div1"]/p[8]/div/input') dept_field.send_keys(department[x]) man_field = browser.find_element_by_id('StdSf_70_Manufacturer_txt') #man_field.clear() man_field.send_keys(make[x]) model_field = browser.find_element_by_id('StdSf_70_ModelNumber_txt') #model_field.clear() model_field.send_keys(model[x]) vin_field = browser.find_element_by_id('StdSf_70_SerialNumber_txt') #vin_field.clear() vin_field.send_keys(vin_serial[x]) inv_field = browser.find_element_by_id('StdSf_70_InventoryNumber_txt') #inv_field.clear() inv_field.send_keys(inv_number[x]) const_year_field = browser.find_element_by_id( 'StdSf_70_ConstructionYear_txt')