-
-
Save KostaGorod/a74a734508716eeeb3a5fdfb6dcf3302 to your computer and use it in GitHub Desktop.
Sign Orcanos documents waiting for my signature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ORCANOS_COMPANY= | |
| ORCANOS_USERNAME= | |
| ORCANOS_PASSWORD= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| python-dotenv | |
| playwright |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| from time import sleep | |
| from playwright.sync_api import Playwright, sync_playwright, expect | |
| from dotenv import dotenv_values | |
| def run(playwright: Playwright, username: str, password: str, company: str) -> None: | |
| browser = playwright.chromium.launch(headless=False) | |
| context = browser.new_context() | |
| page = context.new_page() | |
| page.goto(f"https://app.orcanos.com/{company}/web/Account/Login?ReturnUrl=%{company}%2Fweb%2F18%2FQPackItems%2FListing%3FItem%3DTRN_TSK") | |
| page.locator("div").filter(has_text=f"Login to account: {company}").nth(1).click() | |
| page.get_by_placeholder("Please type your Email /").fill(username) | |
| page.get_by_placeholder("Please type your Password").fill(password) | |
| page.get_by_role("button", name="Login").click() | |
| page.goto(f"https://app.orcanos.com/{company}/web/18/QPackItems/Listing?Item=TRN_TSK") | |
| sleep(3) | |
| page.get_by_role("combobox").nth(1).click() | |
| page.get_by_label("All filters").get_by_text("All Document waiting for my signatures", exact=True).click() | |
| sleep(3) | |
| def sign_document(doc_link: str, page): | |
| page.goto(doc_link) | |
| page.get_by_placeholder("Please enter Username.").fill(username) | |
| page.get_by_placeholder("Please type your Password").fill(password) | |
| page.get_by_role("button", name="Approve", exact=True).click() | |
| tasks = page.get_by_role("row", name="TRN") | |
| if tasks.get_by_role("gridcell", name=username, exact=True) is not None: | |
| for item in tasks.locator(f"a[href*='/{company}/web/Async/SignDocument']").all(): | |
| relative_link = item.get_attribute("href") | |
| base_url = "https://app.orcanos.com/" | |
| full_url = base_url.rstrip('/') + '/' + relative_link.lstrip('/') | |
| new_page = context.new_page() | |
| sign_document(doc_link=full_url, page=new_page) | |
| new_page.close() | |
| # --------------------- | |
| context.close() | |
| browser.close() | |
| with sync_playwright() as playwright: | |
| config = dotenv_values(".env") | |
| username = config["ORCANOS_USERNAME"] | |
| password = config["ORCANOS_PASSWORD"] | |
| company = config["ORCANOS_COMPANY"] | |
| run(playwright, username, password, company) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment