Pass URLs on recursion

This commit is contained in:
2024-02-16 13:33:11 -08:00
parent b9cebe8f5b
commit 37c1c75053
3 changed files with 21 additions and 11 deletions

View File

@@ -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()

View File

@@ -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! ヾ(˶ᵔ ᗜ ᵔ˶)")

View File

@@ -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! ✧⋆٩(ˊˋ )و ♡✧")