V
V
vadimeasy2021-11-03 13:15:36
Python
vadimeasy, 2021-11-03 13:15:36

How to do sequential check?

Good afternoon. Please tell me, I am writing a program to check the data on the site of certain keys. There are a certain number of these keys for verification, my knowledge of programming was enough to simply ask a person through the command line.

guid = str(input('Введите GUID:'))
id_tasks = int(input('Ведите цифры ID задачи:'))

variable guidand id_tasksinterconnected. id_tasksis responsible for sending a comment about the event checked by in my workspace. guid
Here is the entire processing code:
url = "https://cerberus.vetrf.ru/cerberus/actualObject/pub/actualInfo/"
options = Options()
options.headless = True

try:
    guid = str(input('Введите GUID:'))
    id_tasks = int(input('Ведите цифры ID задачи:'))
    options = Options()
    options.headless = True
    # driver = webdriver.Chrome()
    driver = webdriver.Chrome(chrome_options=options)
    
    driver.get(url=url)
    driver.find_element_by_tag_name('input').send_keys(guid)
    driver.find_element_by_tag_name('button').click()
    print('Запрос выполняется...')
    time.sleep(0.5)
    
    print ('Осталось совсем чуть-чуть...')

    if driver.find_elements_by_xpath('//span[@class="label label-success"][1]'):
        if True:
            request = pyrus.models.requests.TaskCommentRequest(text="Подтверждена", action="")
            task = pyrus_client.comment_task(id_tasks, request).task
            print('Подтверждена')

    elif driver.find_elements_by_xpath('//span[@class="label label-warning"][1]'):
        if True:
            print('Не подтверждена')
            # window2 = Tk()
            # window2.title('Не подтверждена')
            # window2.geometry('300x250')

            # window2.mainloop()

    elif driver. find_elements_by_tag_name("tbody"):
        if True:
            print('Ошибка, площадка не найдена.')

except Exception as ex:
    print(ex)
finally:
    driver.close()
    driver.quit()

Can you please help me with the Excel library? The main question is that you need to check the key (guid) and, if the answer is positive, send it to id_tasks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-11-03
@Vindicar

Do not write a sheet of code, but break the task into components.
First, refactor (remake) your code into a function like this:

def is_guid_accepted(guid: str) -> bool:
    #тут код

Those. a function that takes a GUID and returns either True (confirmed) or False (unverified). On error, you can throw an exception, or return False too.
After that, the task will become easier.
1. Read the contents of the .xlsx file, if you really want an excel (or maybe csv? It will be easier), extract a list of GUIDs and task_id from it. Googled.
2. For each GUID in the list, call the function above.
3. If the function returned True, then add task_id to the list of successful ones.
4. For each task_id in the list of successful send an alert. You can see how.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question