From 37c1c75053b60ccea1babfe212d682527b269fff Mon Sep 17 00:00:00 2001 From: Hex Ripley Date: Fri, 16 Feb 2024 13:33:11 -0800 Subject: [PATCH] Pass URLs on recursion --- AssignerPal.py | 8 ++------ AutoColor.py | 17 ++++++++++++----- AutoTicket.py | 7 +++++++ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/AssignerPal.py b/AssignerPal.py index 5fd5396..f287354 100644 --- a/AssignerPal.py +++ b/AssignerPal.py @@ -1,9 +1,4 @@ from selenium import webdriver -from selenium.webdriver.common.keys import Keys -from selenium.webdriver.common.by import By -from selenium.webdriver.support.wait import WebDriverWait -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.common.action_chains import ActionChains import AutoTicket import AutoColor import json @@ -55,7 +50,7 @@ def choice(urls,users,driver): AutoTicket.auto_ticket(urls,users,driver) if "di" in user_choice.lower(): AutoColor.tag_assist(urls,driver) - print("More?") + print("Go back to Directly or Tickets choice?") if input("y/n : ") == "y": choice(urls,users,driver) @@ -71,5 +66,6 @@ def main(): with open('team.json', 'r') as file: users = json.load(file) choice(urls,users,driver) + driver.close() main() \ No newline at end of file diff --git a/AutoColor.py b/AutoColor.py index ab1340e..f2de7e1 100644 --- a/AutoColor.py +++ b/AutoColor.py @@ -4,6 +4,7 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.action_chains import ActionChains +import datetime # Condensed string finder for lists of strings def found_string(string_list, main_string): @@ -33,11 +34,13 @@ def next_string(list_of_strings): # Assign steps in order of queue list without checking tag_count def dumb_make_tags(queues,tags,driver): + ac = ActionChains(driver) original_window = driver.current_window_handle next_queue = next_string(queues) for tag in tags: if found_string(queues, tag.text.lower()) == False: - tag.send_keys(Keys.CONTROL + Keys.ENTER) + driver.execute_script("arguments[0].scrollIntoView(true);", tag) + ac.context_click(tag).perform() WebDriverWait(driver, 10).until(EC.number_of_windows_to_be(2)) for window_handle in driver.window_handles: if window_handle != original_window: @@ -73,10 +76,12 @@ def select_list_item(list_of_strings): # Select every unassigned tag, print queue count, print step name, use user input to choose what tag to assign def guided_make_tags(queues,tags,driver): + ac = ActionChains(driver) original_window = driver.current_window_handle for tag in tags: if found_string(queues, tag.text.lower()) == False: - tag.send_keys(Keys.CONTROL + Keys.ENTER) + driver.execute_script("arguments[0].scrollIntoView(true);", tag) + ac.context_click(tag).perform() WebDriverWait(driver, 10).until(EC.number_of_windows_to_be(2)) for window_handle in driver.window_handles: if window_handle != original_window: @@ -116,12 +121,14 @@ def find_lowest_and_increment(dictionary): # Check which queue has the least number of assigned workflows. def smart_make_tags(queues,tags,driver): + ac = ActionChains(driver) original_window = driver.current_window_handle tag_count = count_tags(queues,tags) for tag in tags: if found_string(queues, tag.text.lower()) == False: lowest_queue = find_lowest_and_increment(tag_count) - tag.send_keys(Keys.CONTROL + Keys.ENTER) + driver.execute_script("arguments[0].scrollIntoView(true);", tag) + ac.context_click(tag).perform() WebDriverWait(driver, 10).until(EC.number_of_windows_to_be(2)) for window_handle in driver.window_handles: if window_handle != original_window: @@ -248,9 +255,9 @@ def tag_assist(urls,driver): tags = driver.find_elements(By.CSS_SELECTOR, "td.tag") automation_picker(queues,tags,driver) print("Done! ✧⋆٩(ˊ ᗜ ˋ )و ♡✧") - print("Wanna do another? y/n") + print("Wanna do another queue? y/n") answer = input() if answer == "y": - tag_assist(queues) + tag_assist(urls,driver) else: print("Goodbye! ヾ(˶ᵔ ᗜ ᵔ˶)") \ No newline at end of file diff --git a/AutoTicket.py b/AutoTicket.py index 22640f1..3ed0ae0 100644 --- a/AutoTicket.py +++ b/AutoTicket.py @@ -4,6 +4,8 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.action_chains import ActionChains +import datetime +import json def get_filters(driver): print("Setting up filters...") @@ -66,12 +68,16 @@ def assign_tickets(namecount,driver): owner_field.send_keys(Keys.ENTER) print("Check to see if this worked, then press enter") input() + #assigned_json[lowest_name] += 1 driver.find_element(By.CLASS_NAME, 'update').click() driver.close() driver.switch_to.window(original_window) +#assigned_json = {} def auto_ticket(urls,users,driver): + #for user in users: + # assigned_json[user] = 0 driver.get(urls['TICKETS']) print("") print("Please use the browser to log in. I won't look (づ_ど)") @@ -84,4 +90,5 @@ def auto_ticket(urls,users,driver): namecount = get_names(users,driver) print(namecount) assign_tickets(namecount,driver) + #print(assigned_json) print("Done! ✧⋆٩(ˊ ᗜ ˋ )و ♡✧") \ No newline at end of file