|
| 1 | +import os |
| 2 | + |
| 3 | +from flask import json |
| 4 | +from patchwork.step import Step |
| 5 | +from patchwork.steps import BrowserUse |
| 6 | +from typing import Tuple, List |
| 7 | + |
| 8 | +upi_url = "https://10.142.27.8/UPI/login" |
| 9 | + |
| 10 | +m2p_url = "http://qa-jiocbs.m2pfintech.dev/dashboard/login" |
| 11 | +username = "tushar11.nikam" |
| 12 | +password = "Test@123" |
| 13 | +files: List[Tuple[str, List[str]]] = [("POS Settlement", []), ("IMPS Settlement", []), ("Wallet Transactions", [])] |
| 14 | +end_of_task = "Then leave the rest for the user. Your job is done." |
| 15 | + |
| 16 | + |
| 17 | +browser_use_defaults = dict( |
| 18 | + google_api_key=os.getenv("GOOGLE_API_KEY"), |
| 19 | + generate_gif=True, |
| 20 | + headless=False, |
| 21 | + task_value={}, |
| 22 | +) |
| 23 | + |
| 24 | + |
| 25 | +def create_inputs(task: str, **kwargs): |
| 26 | + cloned_dict = browser_use_defaults.copy() |
| 27 | + cloned_dict.update(**kwargs) |
| 28 | + cloned_dict["task"] = task + "\n" + end_of_task |
| 29 | + return cloned_dict |
| 30 | + |
| 31 | + |
| 32 | +class Temp(Step): |
| 33 | + def run(self): |
| 34 | + if 1 == 1: |
| 35 | + return BrowserUse( |
| 36 | + create_inputs( |
| 37 | + task="Go to google.com.", |
| 38 | + ) |
| 39 | + ).run() |
| 40 | + BrowserUse( |
| 41 | + create_inputs( |
| 42 | + task=""" |
| 43 | +Go to {{m2p_url}} |
| 44 | +Click on the login button |
| 45 | +Enter the username {{username}} |
| 46 | +Enter the password {{password}} |
| 47 | +Click on the login button. |
| 48 | +""", |
| 49 | + task_value={ |
| 50 | + "m2p_url": m2p_url, |
| 51 | + "username": username, |
| 52 | + "password": password, |
| 53 | + }, |
| 54 | + ) |
| 55 | + ).run() |
| 56 | + BrowserUse( |
| 57 | + create_inputs( |
| 58 | + task=""" |
| 59 | +Then from the left sidebar, click on "Integrated Channels". |
| 60 | +Once the page loads, click on "Reconciliation" tab. |
| 61 | +On the left, click on "Upload File" link. |
| 62 | +""", |
| 63 | + ) |
| 64 | + ).run() |
| 65 | + file_upload_outputs = [] |
| 66 | + for file_type, file_paths in files: |
| 67 | + if len(file_paths) == 0: |
| 68 | + continue |
| 69 | + BrowserUse( |
| 70 | + create_inputs( |
| 71 | + task=""" |
| 72 | +Select file type as "{{file_type}}" and upload the following files: |
| 73 | +
|
| 74 | +<files> |
| 75 | +{{files}} |
| 76 | +</files> |
| 77 | +""", |
| 78 | + task_value={"file_type": file_type, "files": json.dumps(file_paths)}, |
| 79 | + ), |
| 80 | + ).run() |
| 81 | + |
| 82 | + BrowserUse( |
| 83 | + create_inputs( |
| 84 | + task=""" |
| 85 | +From the left sidebar, click on "Reconciliation" tab. |
| 86 | +Click on the select box and select "UPI" option. |
| 87 | +Click on "Apply Reconciliation" button. |
| 88 | +""", |
| 89 | + task_value={}, |
| 90 | + ) |
| 91 | + ).run() |
| 92 | + |
| 93 | + return {} |
0 commit comments