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 find_schedule(schedule, location_based=0): browser.implicitly_wait(10) if location_based == 0: browser.get( 'https://sysco.sprocketcmms.com/Default.aspx?screen=PM%20Projects&SSF=-108' ) print('---> Loading Equipment Based View') elif location_based == 1: browser.get( 'https://sysco.sprocketcmms.com/Default.aspx?screen=PM%20Projects&SSF=244' ) print('---> Loading Location Based View') else: print( '--->!! Value outside of defined parameters\nlocation_based=0\nor\nlocation_based=1' ) project_link = schedule time.sleep(1) search_link = browser.find_element_by_link_text('Search') time.sleep(1) search_link.click() pm_number_field = browser.find_element_by_id('PMNumber_txt3') pm_number_field.clear() pm_number_field.send_keys(schedule) search_button = browser.find_element_by_id('SearchScreenBtnSearch') search_button.click() time.sleep(1) browser.find_element_by_partial_link_text(project_link).click()
def correct_pmp_name(new_sch_name, archive_flag=1): browser.implicitly_wait(10) details_name = browser.find_element_by_id('Name_txt') details_name.clear() details_name.send_keys(new_sch_name) if archive_flag == 0: archive_flag_box = browser.find_element_by_id('Archived_chk') archive_flag_box.click() save_details = browser.find_element_by_link_text('Save') save_details.click() time.sleep(3)
def update_employee_tab(): browser.implicitly_wait(10) employee_tab = browser.find_element_by_id('liEmployee') employee_tab.click() time.sleep(1) remove_web_requester = browser.find_element_by_id('StdSf_102_License_ddl') remove_web_requester.send_keys('User') save_update_employee = browser.find_element_by_id('liSave') save_update_employee.click() time.sleep(5) browser.switch_to.alert.accept() time.sleep(1)
def archive_item(inventoryItemId): browser.implicitly_wait(60) base_url = 'https://sysco.sprocketcmms.com/Default.aspx?screen=Inventory%20Item&InstanceName=' target_item_url = '{}{}'.format(base_url, inventoryItemId) browser.get(target_item_url) time.sleep(5) archive_chk_box = browser.find_element_by_id('StdSf12_Archived_chk') archive_chk_box.click() save_archive = browser.find_element_by_id('liSave') save_archive.click() time.sleep(5) browser.find_element_by_id('liExit').click() time.sleep(5)
def equipment_page(unit): # Find and select Equipment browser.implicitly_wait(15) browser.get( 'https://sysco.sprocketcmms.com/Default.aspx?screen=Equipment&SSF=-102' ) search_field = browser.find_element_by_link_text('Search') search_field.click() equip_search = browser.find_element_by_id('Equipment_txt4') equip_search.clear() equip_search.send_keys(unit) searchButton = browser.find_element_by_id('SearchScreenBtnSearch') searchButton.click() time.sleep(5) unit_link = browser.find_element_by_link_text(unit) unit_link.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 create_new(option, start, length): browser.implicitly_wait(15) war_tab = browser.find_element_by_link_text('Warranty') time.sleep(1) war_tab.click() time.sleep(1) war_link = browser.find_element_by_id('newWarranty_anchor') war_link.click() war_name = browser.find_element_by_id('newWarranty_WarrantyID') war_name.send_keys(option) war_start = browser.find_element_by_id('newWarranty_StartDate') war_start.clear() war_start.send_keys(start) war_end = browser.find_element_by_id('newWarranty_EndDate') war_end.clear() war_end.send_keys(length) war_save = browser.find_element_by_id('newWarranty_save') war_save.click() time.sleep(3)
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() target_item_list = 'target_clone.csv' col_names = ['clone_name'] data = pandas.read_csv(target_item_list, names=col_names) clone_name = data.clone_name.tolist() browser.implicitly_wait(60) login(bot1, password) set_site('Global Site Code') counter = len(clone_name) x = 0 while x <= counter: main_to_target = 'TEST_CABL_FSI_Monthly Cooler v2 by Aisle MAIN' clone_to_target = 'TEST_CABL_FSI_Monthly Cooler v2 by Aisle MAIN Clone' try: x += 1 print('{} of {}'.format(x, counter)) time.sleep(1) find_main(main_to_target) time.sleep(1)
def page_error(unit): file = open('ErrorLog.txt', 'a') file.write('{} error\n'.format(unit)) file.close() target_file = 'add_user_group.csv' col_names = ['target_user', 'target_site', 'override_workday'] data = pandas.read_csv(target_file, names=col_names) target_user = data.target_user.tolist() target_site = data.target_site.tolist() override_workday = data.override_workday.tolist() counter = len(target_user) x = 0 browser.implicitly_wait(15) login(bot2, password) set_site('Global Site Code') while x <= counter: try: x = x + 1 print('Starting {} of {}'.format(x, (counter - 1))) add_safety(target_user[x], override_workday[x]) page_final(target_user[x]) print('---> User {} updated.'.format(target_user[x])) except IndexError: print('Script complete!!') break