Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all auto tests back with new updates #2552

Merged
merged 10 commits into from
Jun 5, 2024

Conversation

A-Harby
Copy link
Contributor

@A-Harby A-Harby commented Apr 14, 2024

Description

add all automation tests back and update (homepage, profile manager, twin, transfer, bridge) pages.

Related Issue

#1285 (comment)
#1667

Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstrings
  • Screenshots/Video attached (needed for UI changes)

@Mahmoud-Emad
Copy link
Contributor

@khaledyoussef24 Can you please give it a look?

@AlaaElattar
Copy link
Contributor

  • test_dedicate.py kept failing
Screencast.from.04-15-2024.01.08.14.PM.webm

Copy link
Contributor

@zaelgohary zaelgohary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a section on how to run these tests in the docs?

@A-Harby
Copy link
Contributor Author

A-Harby commented Apr 15, 2024

Can we add a section on how to run these tests in the docs?

I updated the docs 893cf3a

  • test_dedicate.py kept failing

I know I only updated the (home page, profile manager, twin, transfer, bridge) test pages because the PR is already big enough. and I'll create more PRs to update other pages and add new tests.

@Mahmoud-Emad
Copy link
Contributor

@A-Harby
What is the status here? if the work still in progress please daft if :)

@A-Harby
Copy link
Contributor Author

A-Harby commented May 1, 2024

@A-Harby What is the status here? if the work still in progress please daft if :)

No, the PR is done and waiting for review.

Copy link
Contributor

@zaelgohary zaelgohary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bridge test is failling in test_check_withdraw_invalid_tft_amount

====================================================================== test session starts ======================================================================
platform linux -- Python 3.8.10, pytest-7.4.0, pluggy-1.5.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/zainab/repos/tfgrid-sdk-ts/packages/playground/tests/frontend_selenium
collected 10 items                                                                                                                                              

tests/TFChain/test_bridge.py::test_navigate_bridge PASSED                                                                                                 [ 10%]
tests/TFChain/test_bridge.py::test_choose_deposit PASSED                                                                                                  [ 20%]
tests/TFChain/test_bridge.py::test_choose_withdraw PASSED                                                                                                 [ 30%]
tests/TFChain/test_bridge.py::test_how_it_done PASSED                                                                                                     [ 40%]
tests/TFChain/test_bridge.py::test_check_deposit PASSED                                                                                                   [ 50%]
tests/TFChain/test_bridge.py::test_check_withdraw_stellar PASSED                                                                                          [ 60%]
tests/TFChain/test_bridge.py::test_check_withdraw_invalid_stellar PASSED                                                                                  [ 70%]
tests/TFChain/test_bridge.py::test_check_withdraw_tft_amount PASSED                                                                                       [ 80%]
tests/TFChain/test_bridge.py::test_check_withdraw_invalid_tft_amount FAILED                                                                               [ 90%]
tests/TFChain/test_bridge.py::test_check_withdraw PASSED                                                                                                  [100%]

=========================================================================== FAILURES ============================================================================
____________________________________________________________ test_check_withdraw_invalid_tft_amount _____________________________________________________________

browser = <selenium.webdriver.chrome.webdriver.WebDriver (session="093502ada9494b738f2ec3e49e637a90")>

    def test_check_withdraw_invalid_tft_amount(browser):
        """
          Test Case: TC1144 - Check withdraw invalid TFT amount
          Steps:
              - Navigate to the dashboard.
              - Login.
              - Click on bridge from side menu.
              - Click on chain list.
              - Click on withdraw button.
              - Put amount of tft you want to send.
              - Click on close button.
          Result: Alert with message "Amount cannot be negative or 0" should be displayed.
        """
        bridge_page = before_test_setup(browser)
>       balance = bridge_page.setup_widthdraw_address(get_stellar_address())

tests/TFChain/test_bridge.py:194: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pages/bridge.py:91: in setup_widthdraw_address
    self.browser.find_element(*self.stellar_address).send_keys(Keys.CONTROL + "a")
/home/zainab/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py:739: in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
/home/zainab/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py:345: in execute
    self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x7f406acfef70>
response = {'status': 404, 'value': '{"value":{"error":"no such element","message":"no such element: Unable to locate element: {\...wn>\\n#16 0x5637b5e7f1d7 \\u003Cunknown>\\n#17 0x5637b5e91124 \\u003Cunknown>\\n#18 0x7fc152054609 start_thread\\n"}}'}

    def check_response(self, response: Dict[str, Any]) -> None:
        """Checks that a JSON response from the WebDriver does not have an
        error.
    
        :Args:
         - response - The JSON response from the WebDriver server as a dictionary
           object.
    
        :Raises: If the response contains an error message.
        """
        status = response.get("status", None)
        if not status or status == ErrorCode.SUCCESS:
            return
        value = None
        message = response.get("message", "")
        screen: str = response.get("screen", "")
        stacktrace = None
        if isinstance(status, int):
            value_json = response.get("value", None)
            if value_json and isinstance(value_json, str):
                import json
    
                try:
                    value = json.loads(value_json)
                    if len(value) == 1:
                        value = value["value"]
                    status = value.get("error", None)
                    if not status:
                        status = value.get("status", ErrorCode.UNKNOWN_ERROR)
                        message = value.get("value") or value.get("message")
                        if not isinstance(message, str):
                            value = message
                            message = message.get("message")
                    else:
                        message = value.get("message", None)
                except ValueError:
                    pass
    
        exception_class: Type[WebDriverException]
        e = ErrorCode()
        error_codes = [item for item in dir(e) if not item.startswith("__")]
        for error_code in error_codes:
            error_info = getattr(ErrorCode, error_code)
            if isinstance(error_info, list) and status in error_info:
                exception_class = getattr(ExceptionMapping, error_code, WebDriverException)
                break
        else:
            exception_class = WebDriverException
    
        if not value:
            value = response["value"]
        if isinstance(value, str):
            raise exception_class(value)
        if message == "" and "message" in value:
            message = value["message"]
    
        screen = None  # type: ignore[assignment]
        if "screen" in value:
            screen = value["screen"]
    
        stacktrace = None
        st_value = value.get("stackTrace") or value.get("stacktrace")
        if st_value:
            if isinstance(st_value, str):
                stacktrace = st_value.split("\n")
            else:
                stacktrace = []
                try:
                    for frame in st_value:
                        line = frame.get("lineNumber", "")
                        file = frame.get("fileName", "<anonymous>")
                        if line:
                            file = f"{file}:{line}"
                        meth = frame.get("methodName", "<anonymous>")
                        if "className" in frame:
                            meth = f"{frame['className']}.{meth}"
                        msg = "    at %s (%s)"
                        msg = msg % (meth, file)
                        stacktrace.append(msg)
                except TypeError:
                    pass
        if exception_class == UnexpectedAlertPresentException:
            alert_text = None
            if "data" in value:
                alert_text = value["data"].get("text")
            elif "alert" in value:
                alert_text = value["alert"].get("text")
            raise exception_class(message, screen, stacktrace, alert_text)  # type: ignore[call-arg]  # mypy is not smart enough here
>       raise exception_class(message, screen, stacktrace)
E       selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[2]/div[35]/div[2]/div/div[3]/div[1]/div[1]/div/div[3]/input"}
E         (Session info: chrome=120.0.6099.129); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
E       Stacktrace:
E       #0 0x5637b5e91f83 <unknown>
E       #1 0x5637b5b4acf7 <unknown>
E       #2 0x5637b5b9a99e <unknown>
E       #3 0x5637b5b9aaa1 <unknown>
E       #4 0x5637b5be5d64 <unknown>
E       #5 0x5637b5bc40dd <unknown>
E       #6 0x5637b5be3006 <unknown>
E       #7 0x5637b5bc3e53 <unknown>
E       #8 0x5637b5b8bdd4 <unknown>
E       #9 0x5637b5b8d1de <unknown>
E       #10 0x5637b5e56531 <unknown>
E       #11 0x5637b5e5a455 <unknown>
E       #12 0x5637b5e42f55 <unknown>
E       #13 0x5637b5e5b0ef <unknown>
E       #14 0x5637b5e2699f <unknown>
E       #15 0x5637b5e7f008 <unknown>
E       #16 0x5637b5e7f1d7 <unknown>
E       #17 0x5637b5e91124 <unknown>
E       #18 0x7fc152054609 start_thread

/home/zainab/.local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py:229: NoSuchElementException
==================================================================== short test summary info ====================================================================
FAILED tests/TFChain/test_bridge.py::test_check_withdraw_invalid_tft_amount - selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[2]/div[3...
============================================================ 1 failed, 9 passed in 239.78s (0:03:59) ============================================================

Copy link
Contributor

@zaelgohary zaelgohary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some transfer tests failed without any valid reason.

====================================================================== test session starts ======================================================================
platform linux -- Python 3.8.10, pytest-7.4.0, pluggy-1.5.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/zainab/repos/tfgrid-sdk-ts/packages/playground/tests/frontend_selenium
collected 8 items                                                                                                                                               

tests/TFChain/test_transfer.py::test_transfer_page PASSED                                                                                                 [ 12%]
tests/TFChain/test_transfer.py::test_valid_address PASSED                                                                                                 [ 25%]
tests/TFChain/test_transfer.py::test_invalid_address PASSED                                                                                               [ 37%]
tests/TFChain/test_transfer.py::test_twin_id PASSED                                                                                                       [ 50%]
tests/TFChain/test_transfer.py::test_valid_amount PASSED                                                                                                  [ 62%]
tests/TFChain/test_transfer.py::test_invalid_amount PASSED                                                                                                [ 75%]
tests/TFChain/test_transfer.py::test_transfer_tfts_on_tfchain_by_twin_address PASSED                                                                      [ 87%]
tests/TFChain/test_transfer.py::test_transfer_tfts_on_tfchain_by_twin_id PASSED                                                                           [100%]

================================================================= 8 passed in 161.92s (0:02:41) =================================================================
➜  frontend_selenium git:(development_add_auto_tests) ✗ python3 -m pytest -v tests/TFChain/test_twin.py    
====================================================================== test session starts ======================================================================
platform linux -- Python 3.8.10, pytest-7.4.0, pluggy-1.5.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/zainab/repos/tfgrid-sdk-ts/packages/playground/tests/frontend_selenium
collected 4 items                                                                                                                                               

tests/TFChain/test_twin.py::test_twin_details PASSED                                                                                                      [ 25%]
tests/TFChain/test_twin.py::test_edit_twin_email PASSED                                                                                                   [ 50%]
tests/TFChain/test_twin.py::test_get_tft PASSED                                                                                                           [ 75%]
tests/TFChain/test_twin.py::test_twin_links PASSED                                                                                                        [100%]

================================================================= 4 passed in 103.29s (0:01:43) =================================================================
➜  frontend_selenium git:(development_add_auto_tests) ✗ python3 -m pytest -v tests/TFChain/test_bridge.py 
====================================================================== test session starts ======================================================================
platform linux -- Python 3.8.10, pytest-7.4.0, pluggy-1.5.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/zainab/repos/tfgrid-sdk-ts/packages/playground/tests/frontend_selenium
collected 10 items                                                                                                                                              

tests/TFChain/test_bridge.py::test_navigate_bridge PASSED                                                                                                 [ 10%]
tests/TFChain/test_bridge.py::test_choose_deposit PASSED                                                                                                  [ 20%]
tests/TFChain/test_bridge.py::test_choose_withdraw PASSED                                                                                                 [ 30%]
tests/TFChain/test_bridge.py::test_how_it_done PASSED                                                                                                     [ 40%]
tests/TFChain/test_bridge.py::test_check_deposit PASSED                                                                                                   [ 50%]
tests/TFChain/test_bridge.py::test_check_withdraw_stellar PASSED                                                                                          [ 60%]
tests/TFChain/test_bridge.py::test_check_withdraw_invalid_stellar PASSED                                                                                  [ 70%]
tests/TFChain/test_bridge.py::test_check_withdraw_tft_amount FAILED                                                                                       [ 80%]
tests/TFChain/test_bridge.py::test_check_withdraw_invalid_tft_amount FAILED                                                                               [ 90%]
tests/TFChain/test_bridge.py::test_check_withdraw PASSED                                                                                                  [100%]

=========================================================================== FAILURES ============================================================================
________________________________________________________________ test_check_withdraw_tft_amount _________________________________________________________________

browser = <selenium.webdriver.chrome.webdriver.WebDriver (session="d113ddb109ebef980475f815771df618")>

    def test_check_withdraw_tft_amount(browser):
        """
          Test Case: TC1131 check withdraw tft amount
          Steps:
              - Navigate to the dashboard.
              - Login.
              - Click on bridge from side menu.
              - Click on chain list.
              - Click on withdraw button.
              - Put amount of tft you want to send.
              - Click on close button.
          Result: Assert that the amount of tft is right.
        """
        bridge_page = before_test_setup(browser)
>       balance = bridge_page.setup_widthdraw_address(get_stellar_address())

tests/TFChain/test_bridge.py:173: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pages/bridge.py:91: in setup_widthdraw_address
    self.browser.find_element(*self.stellar_address).send_keys(Keys.CONTROL + "a")
/home/zainab/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py:739: in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
/home/zainab/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py:345: in execute
    self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x7f2a53d32130>
response = {'status': 404, 'value': '{"value":{"error":"no such element","message":"no such element: Unable to locate element: {\...wn>\\n#16 0x55f323ae41d7 \\u003Cunknown>\\n#17 0x55f323af6124 \\u003Cunknown>\\n#18 0x7fa38bbdf609 start_thread\\n"}}'}

    def check_response(self, response: Dict[str, Any]) -> None:
        """Checks that a JSON response from the WebDriver does not have an
        error.
    
        :Args:
         - response - The JSON response from the WebDriver server as a dictionary
           object.
    
        :Raises: If the response contains an error message.
        """
        status = response.get("status", None)
        if not status or status == ErrorCode.SUCCESS:
            return
        value = None
        message = response.get("message", "")
        screen: str = response.get("screen", "")
        stacktrace = None
        if isinstance(status, int):
            value_json = response.get("value", None)
            if value_json and isinstance(value_json, str):
                import json
    
                try:
                    value = json.loads(value_json)
                    if len(value) == 1:
                        value = value["value"]
                    status = value.get("error", None)
                    if not status:
                        status = value.get("status", ErrorCode.UNKNOWN_ERROR)
                        message = value.get("value") or value.get("message")
                        if not isinstance(message, str):
                            value = message
                            message = message.get("message")
                    else:
                        message = value.get("message", None)
                except ValueError:
                    pass
    
        exception_class: Type[WebDriverException]
        e = ErrorCode()
        error_codes = [item for item in dir(e) if not item.startswith("__")]
        for error_code in error_codes:
            error_info = getattr(ErrorCode, error_code)
            if isinstance(error_info, list) and status in error_info:
                exception_class = getattr(ExceptionMapping, error_code, WebDriverException)
                break
        else:
            exception_class = WebDriverException
    
        if not value:
            value = response["value"]
        if isinstance(value, str):
            raise exception_class(value)
        if message == "" and "message" in value:
            message = value["message"]
    
        screen = None  # type: ignore[assignment]
        if "screen" in value:
            screen = value["screen"]
    
        stacktrace = None
        st_value = value.get("stackTrace") or value.get("stacktrace")
        if st_value:
            if isinstance(st_value, str):
                stacktrace = st_value.split("\n")
            else:
                stacktrace = []
                try:
                    for frame in st_value:
                        line = frame.get("lineNumber", "")
                        file = frame.get("fileName", "<anonymous>")
                        if line:
                            file = f"{file}:{line}"
                        meth = frame.get("methodName", "<anonymous>")
                        if "className" in frame:
                            meth = f"{frame['className']}.{meth}"
                        msg = "    at %s (%s)"
                        msg = msg % (meth, file)
                        stacktrace.append(msg)
                except TypeError:
                    pass
        if exception_class == UnexpectedAlertPresentException:
            alert_text = None
            if "data" in value:
                alert_text = value["data"].get("text")
            elif "alert" in value:
                alert_text = value["alert"].get("text")
            raise exception_class(message, screen, stacktrace, alert_text)  # type: ignore[call-arg]  # mypy is not smart enough here
>       raise exception_class(message, screen, stacktrace)
E       selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[2]/div[35]/div[2]/div/div[3]/div[1]/div[1]/div/div[3]/input"}
E         (Session info: chrome=120.0.6099.129); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
E       Stacktrace:
E       #0 0x55f323af6f83 <unknown>
E       #1 0x55f3237afcf7 <unknown>
E       #2 0x55f3237ff99e <unknown>
E       #3 0x55f3237ffaa1 <unknown>
E       #4 0x55f32384ad64 <unknown>
E       #5 0x55f3238290dd <unknown>
E       #6 0x55f323848006 <unknown>
E       #7 0x55f323828e53 <unknown>
E       #8 0x55f3237f0dd4 <unknown>
E       #9 0x55f3237f21de <unknown>
E       #10 0x55f323abb531 <unknown>
E       #11 0x55f323abf455 <unknown>
E       #12 0x55f323aa7f55 <unknown>
E       #13 0x55f323ac00ef <unknown>
E       #14 0x55f323a8b99f <unknown>
E       #15 0x55f323ae4008 <unknown>
E       #16 0x55f323ae41d7 <unknown>
E       #17 0x55f323af6124 <unknown>
E       #18 0x7fa38bbdf609 start_thread

/home/zainab/.local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py:229: NoSuchElementException
____________________________________________________________ test_check_withdraw_invalid_tft_amount _____________________________________________________________

browser = <selenium.webdriver.chrome.webdriver.WebDriver (session="56af5dbd7f0532b32398034ea932fb38")>

    def test_check_withdraw_invalid_tft_amount(browser):
        """
          Test Case: TC1144 - Check withdraw invalid TFT amount
          Steps:
              - Navigate to the dashboard.
              - Login.
              - Click on bridge from side menu.
              - Click on chain list.
              - Click on withdraw button.
              - Put amount of tft you want to send.
              - Click on close button.
          Result: Alert with message "Amount cannot be negative or 0" should be displayed.
        """
        bridge_page = before_test_setup(browser)
>       balance = bridge_page.setup_widthdraw_address(get_stellar_address())

tests/TFChain/test_bridge.py:194: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pages/bridge.py:91: in setup_widthdraw_address
    self.browser.find_element(*self.stellar_address).send_keys(Keys.CONTROL + "a")
/home/zainab/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py:739: in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
/home/zainab/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py:345: in execute
    self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x7f2a53c055e0>
response = {'status': 404, 'value': '{"value":{"error":"no such element","message":"no such element: Unable to locate element: {\...wn>\\n#16 0x56377726b1d7 \\u003Cunknown>\\n#17 0x56377727d124 \\u003Cunknown>\\n#18 0x7fb543cdb609 start_thread\\n"}}'}

    def check_response(self, response: Dict[str, Any]) -> None:
        """Checks that a JSON response from the WebDriver does not have an
        error.
    
        :Args:
         - response - The JSON response from the WebDriver server as a dictionary
           object.
    
        :Raises: If the response contains an error message.
        """
        status = response.get("status", None)
        if not status or status == ErrorCode.SUCCESS:
            return
        value = None
        message = response.get("message", "")
        screen: str = response.get("screen", "")
        stacktrace = None
        if isinstance(status, int):
            value_json = response.get("value", None)
            if value_json and isinstance(value_json, str):
                import json
    
                try:
                    value = json.loads(value_json)
                    if len(value) == 1:
                        value = value["value"]
                    status = value.get("error", None)
                    if not status:
                        status = value.get("status", ErrorCode.UNKNOWN_ERROR)
                        message = value.get("value") or value.get("message")
                        if not isinstance(message, str):
                            value = message
                            message = message.get("message")
                    else:
                        message = value.get("message", None)
                except ValueError:
                    pass
    
        exception_class: Type[WebDriverException]
        e = ErrorCode()
        error_codes = [item for item in dir(e) if not item.startswith("__")]
        for error_code in error_codes:
            error_info = getattr(ErrorCode, error_code)
            if isinstance(error_info, list) and status in error_info:
                exception_class = getattr(ExceptionMapping, error_code, WebDriverException)
                break
        else:
            exception_class = WebDriverException
    
        if not value:
            value = response["value"]
        if isinstance(value, str):
            raise exception_class(value)
        if message == "" and "message" in value:
            message = value["message"]
    
        screen = None  # type: ignore[assignment]
        if "screen" in value:
            screen = value["screen"]
    
        stacktrace = None
        st_value = value.get("stackTrace") or value.get("stacktrace")
        if st_value:
            if isinstance(st_value, str):
                stacktrace = st_value.split("\n")
            else:
                stacktrace = []
                try:
                    for frame in st_value:
                        line = frame.get("lineNumber", "")
                        file = frame.get("fileName", "<anonymous>")
                        if line:
                            file = f"{file}:{line}"
                        meth = frame.get("methodName", "<anonymous>")
                        if "className" in frame:
                            meth = f"{frame['className']}.{meth}"
                        msg = "    at %s (%s)"
                        msg = msg % (meth, file)
                        stacktrace.append(msg)
                except TypeError:
                    pass
        if exception_class == UnexpectedAlertPresentException:
            alert_text = None
            if "data" in value:
                alert_text = value["data"].get("text")
            elif "alert" in value:
                alert_text = value["alert"].get("text")
            raise exception_class(message, screen, stacktrace, alert_text)  # type: ignore[call-arg]  # mypy is not smart enough here
>       raise exception_class(message, screen, stacktrace)
E       selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[2]/div[35]/div[2]/div/div[3]/div[1]/div[1]/div/div[3]/input"}
E         (Session info: chrome=120.0.6099.129); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
E       Stacktrace:
E       #0 0x56377727df83 <unknown>
E       #1 0x563776f36cf7 <unknown>
E       #2 0x563776f8699e <unknown>
E       #3 0x563776f86aa1 <unknown>
E       #4 0x563776fd1d64 <unknown>
E       #5 0x563776fb00dd <unknown>
E       #6 0x563776fcf006 <unknown>
E       #7 0x563776fafe53 <unknown>
E       #8 0x563776f77dd4 <unknown>
E       #9 0x563776f791de <unknown>
E       #10 0x563777242531 <unknown>
E       #11 0x563777246455 <unknown>
E       #12 0x56377722ef55 <unknown>
E       #13 0x5637772470ef <unknown>
E       #14 0x56377721299f <unknown>
E       #15 0x56377726b008 <unknown>
E       #16 0x56377726b1d7 <unknown>
E       #17 0x56377727d124 <unknown>
E       #18 0x7fb543cdb609 start_thread

/home/zainab/.local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py:229: NoSuchElementException
==================================================================== short test summary info ====================================================================
FAILED tests/TFChain/test_bridge.py::test_check_withdraw_tft_amount - selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[2]/div[3...
FAILED tests/TFChain/test_bridge.py::test_check_withdraw_invalid_tft_amount - selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[2]/div[3...
============================================================ 2 failed, 8 passed in 306.14s (0:05:06) ============================================================

@A-Harby
Copy link
Contributor Author

A-Harby commented May 8, 2024

I have updated the four pages xpaths with all the possible xpaths with improved selectors using button names, input labels, or unique classes if found.

All the tests are passing except for test_edit_twin_email which is failing and has been reported at #2555.

Don't forget to run the latest code locally, and you can use my address for testnet stellar if you want GAK2AN6ZC4REV2GXZPTMJG2JKLRJQX746JNG7ACKNC4RSJE7ETAZSE7D.

I will create another PR for the other pages: farm, node, and dedicate.

@A-Harby A-Harby requested a review from zaelgohary May 8, 2024 15:42
@zaelgohary
Copy link
Contributor

@A-Harby What are the ready tests? Also, can you remove any incomplete tests from this PR and change the PR name and description accordingly?

@A-Harby A-Harby marked this pull request as draft May 12, 2024 13:52
A-Harby and others added 3 commits May 15, 2024 10:17
@A-Harby
Copy link
Contributor Author

A-Harby commented May 15, 2024

Since there were all the automated tests and its workflow, so I had to add them again, and also updated these tests to run on the new UI.
I also removed the dedicated page and updated docs to have all the needed information.

When you run the tests, you will find some failing tests:

  1. All the farm tests will fail until these issues are fixed: 🐞 [Bug]: Search on your farm page only search on the first page #2578, 🐞 [Bug]: Delete IPs should be reflected on the farm IPs table #2610.
  2. The node public config tests will fail until this issue is fixed: 🐞 [Bug]: Node public config validation isn't consistent with the tfchain validation  #2637.
  3. Some tests will fail because of this issue: 🐞 [Bug]: Dashboard stuck on the loading page #2703.

@A-Harby A-Harby marked this pull request as ready for review May 15, 2024 15:40
@Mahmoud-Emad
Copy link
Contributor

Please fix the actions, if you still working on it lets draft it

Copy link
Contributor

@Mahmoud-Emad Mahmoud-Emad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job ya Harby

Copy link
Contributor

@Mahmoud-Emad Mahmoud-Emad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go ahead

@A-Harby A-Harby merged commit b91fde4 into development Jun 5, 2024
3 checks passed
@A-Harby A-Harby deleted the development_add_auto_tests branch June 5, 2024 09:24
@A-Harby A-Harby mentioned this pull request Aug 18, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants