diff --git a/.gitignore b/.gitignore index 131430c..eb56a69 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ demo_repo UiPathProject/ output __pycache__ -notes.txt \ No newline at end of file +notes.txt +*.pyc \ No newline at end of file diff --git a/main.py b/main.py index 202dc4d..6d40206 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,7 @@ from extractor.element_extractor import ElementExtractor from repository.json_storage import JsonStorage from screenshot.screenshot_service import ScreenshotService -from utils.name_utils import get_base_name, get_screen_name +from utils.name_utils import get_base_name, get_screen_name, get_page_key from screenshot.draw_annotator import DrawAnnotator from playwright.sync_api import Error @@ -40,12 +40,13 @@ def main(): def handle_ui_change(): try: + print("Waiting for load state...") page.wait_for_load_state("networkidle") page.wait_for_timeout(700) except: pass - name = get_screen_name(page) + name = get_page_key(page) # prevent duplicate extraction if name == last_screen["name"]: @@ -85,7 +86,10 @@ def on_nav(frame): return try: + print("Navigated to:", frame.url) + print("Waiting for load state...") page.wait_for_load_state("load") + print("Waiting for network idle...") page.wait_for_load_state("networkidle") page.wait_for_timeout(700) except: diff --git a/output/my402955.s4hana.cloud.sap.json b/output/my402955.s4hana.cloud.sap.json deleted file mode 100644 index 4801ccb..0000000 --- a/output/my402955.s4hana.cloud.sap.json +++ /dev/null @@ -1,257 +0,0 @@ -{ - "base_url": "https://my402955.s4hana.cloud.sap/ui#Shell-home", - "pages": { - "SAP S_4HANA Cloud- Partner Demo Customizing Tenant_ Sign In": [ - { - "name": "input_0", - "control_type": "textbox", - "tag": "input", - "text": "", - "type": "text", - "id": "j_username", - "name_attr": "j_username", - "placeholder": "Email or User Name", - "autocomplete": "off", - "title": null, - "label": null, - "class": "fn-input__text-field ids-input ids-input--text ids-input--clear js-has-input-clear js-login-toggle-active-input-user", - "role": null, - "aria_label": null, - "data_testid": null, - "data_id": null, - "selector": "input:not([type='hidden'])", - "box": { - "x": 424.3999938964844, - "y": 262.3999938964844, - "width": 416.0000305175781, - "height": 32 - } - }, - { - "name": "input_1", - "control_type": "password", - "tag": "input", - "text": null, - "type": "password", - "id": "j_password", - "name_attr": "j_password", - "placeholder": "Password", - "autocomplete": "off", - "title": null, - "label": null, - "class": "fn-input__text-field ids-input ids-input--text ids-input--reveal js-login-toggle-active-input-password", - "role": null, - "aria_label": null, - "data_testid": null, - "data_id": null, - "selector": "input:not([type='hidden'])", - "box": { - "x": 424.3999938964844, - "y": 330.3999938964844, - "width": 416.0000305175781, - "height": 32 - } - }, - { - "name": "input_2", - "control_type": "checkbox", - "tag": "input", - "text": null, - "type": "checkbox", - "id": "rememberme", - "name_attr": "rememberme", - "placeholder": null, - "autocomplete": null, - "title": null, - "label": "Keep me signed in", - "class": "fn-checkbox__input", - "role": null, - "aria_label": "Keep me signed in", - "data_testid": null, - "data_id": null, - "selector": "input:not([type='hidden'])", - "box": { - "x": 428.3999938964844, - "y": 378.3999938964844, - "width": 0, - "height": 0 - } - }, - { - "name": "button_3", - "control_type": "button", - "tag": "button", - "text": "Continue", - "type": "submit", - "id": "logOnFormSubmit", - "name_attr": null, - "placeholder": null, - "autocomplete": null, - "title": null, - "label": null, - "class": "ids-button fn-button ids-button--primary fn-button--emphasized ids-button--login js-button-login", - "role": "button", - "aria_label": null, - "data_testid": null, - "data_id": null, - "selector": "button", - "box": { - "x": 755.8375244140625, - "y": 652, - "width": 84.5625, - "height": 32 - } - }, - { - "name": "a_4", - "control_type": "link", - "tag": "a", - "text": "", - "type": null, - "id": null, - "name_attr": null, - "placeholder": null, - "autocomplete": null, - "title": null, - "label": null, - "class": "ids-input-clear js-input-clear", - "role": null, - "aria_label": null, - "data_testid": null, - "data_id": null, - "selector": "a", - "box": { - "x": 424.3999938964844, - "y": 294.3999938964844, - "width": 0, - "height": 0 - } - }, - { - "name": "a_5", - "control_type": "link", - "tag": "a", - "text": "", - "type": null, - "id": null, - "name_attr": null, - "placeholder": null, - "autocomplete": null, - "title": "Show Password", - "label": null, - "class": "ids-input-reveal js-input-reveal", - "role": "button", - "aria_label": null, - "data_testid": null, - "data_id": null, - "selector": "a", - "box": { - "x": 814, - "y": 336.3999938964844, - "width": 19.20001220703125, - "height": 19.20001220703125 - } - }, - { - "name": "a_7", - "control_type": "link", - "tag": "a", - "text": "Forgot password?", - "type": null, - "id": "forgotPasswordLink", - "name_attr": null, - "placeholder": null, - "autocomplete": null, - "title": "Forgot password?", - "label": null, - "class": null, - "role": null, - "aria_label": null, - "data_testid": null, - "data_id": null, - "selector": "a", - "box": { - "x": 721.1625366210938, - "y": 380, - "width": 119.23748779296875, - "height": 16 - } - }, - { - "name": "label_8", - "control_type": "element", - "tag": "label", - "text": "Email or User Name", - "type": null, - "id": "j_username-label", - "name_attr": null, - "placeholder": null, - "autocomplete": null, - "title": null, - "label": null, - "class": "fn-label ids-label", - "role": null, - "aria_label": null, - "data_testid": null, - "data_id": null, - "selector": "label", - "box": { - "x": 424.3999938964844, - "y": 240.8000030517578, - "width": 123.23751831054688, - "height": 16.000015258789062 - } - }, - { - "name": "label_9", - "control_type": "element", - "tag": "label", - "text": "Password", - "type": null, - "id": "j_password-label", - "name_attr": null, - "placeholder": null, - "autocomplete": null, - "title": null, - "label": null, - "class": "fn-label ids-label", - "role": null, - "aria_label": null, - "data_testid": null, - "data_id": null, - "selector": "label", - "box": { - "x": 424.3999938964844, - "y": 308.8000183105469, - "width": 59.475006103515625, - "height": 16 - } - }, - { - "name": "label_10", - "control_type": "element", - "tag": "label", - "text": "Keep me signed in", - "type": null, - "id": "rememberme-label", - "name_attr": null, - "placeholder": null, - "autocomplete": null, - "title": null, - "label": null, - "class": "fn-checkbox fd-margin-bottom--none ids-checkbox-container--option", - "role": null, - "aria_label": null, - "data_testid": null, - "data_id": null, - "selector": "label", - "box": { - "x": 424.3999938964844, - "y": 376.3999938964844, - "width": 143.88754272460938, - "height": 26 - } - } - ] - } -} \ No newline at end of file diff --git a/output/screenshots/my402955.s4hana.cloud.sap/SAP S_4HANA Cloud- Partner Demo Customizing Tenant_ Sign In.png b/output/screenshots/my402955.s4hana.cloud.sap/SAP S_4HANA Cloud- Partner Demo Customizing Tenant_ Sign In.png deleted file mode 100644 index e846a33..0000000 Binary files a/output/screenshots/my402955.s4hana.cloud.sap/SAP S_4HANA Cloud- Partner Demo Customizing Tenant_ Sign In.png and /dev/null differ diff --git a/output/screenshots/my402955.s4hana.cloud.sap/annotated/SAP S_4HANA Cloud- Partner Demo Customizing Tenant_ Sign In_anchor.png b/output/screenshots/my402955.s4hana.cloud.sap/annotated/SAP S_4HANA Cloud- Partner Demo Customizing Tenant_ Sign In_anchor.png deleted file mode 100644 index b4f5ad9..0000000 Binary files a/output/screenshots/my402955.s4hana.cloud.sap/annotated/SAP S_4HANA Cloud- Partner Demo Customizing Tenant_ Sign In_anchor.png and /dev/null differ diff --git a/utils/__pycache__/name_utils.cpython-310.pyc b/utils/__pycache__/name_utils.cpython-310.pyc deleted file mode 100644 index 268f075..0000000 Binary files a/utils/__pycache__/name_utils.cpython-310.pyc and /dev/null differ diff --git a/utils/name_utils.py b/utils/name_utils.py index dbfa6be..fb4efdc 100644 --- a/utils/name_utils.py +++ b/utils/name_utils.py @@ -26,5 +26,33 @@ def get_screen_name(page): return title.strip()[:120] + except: + return "unknown_page" + + +def get_page_key(page): + + try: + url = page.url + + parsed = urlparse(url) + + path = parsed.path.strip("/").replace("/", "_") + + if not path: + path = "home" + + query = parsed.query + + if query: + query = query.replace("=", "_").replace("&", "_") + path = f"{path}_{query}" + + name = f"{parsed.netloc}_{path}" + + name = re.sub(r'[\\/*?:"<>|]', "_", name) + + return name[:200] + except: return "unknown_page" \ No newline at end of file