def _attach_application(sut_identifier, timeout=0):
        exception_message = "Unable to locate application with identifier: {}".format(
            sut_identifier)
        if timeout == 0:
            try:
                return Application.Attach(sut_identifier)
            except WhiteException:
                raise AssertionError(exception_message)

        # using hack due to 2.7 doesnt support nonlocal keyword
        # and inner function cant modify primitive datatypes.
        # aand im trying to avoid calling Application.Attach()
        # multiple times as it allocates memory on python .net
        # side.

        hack = {"sut": None}

        def search_application():
            try:
                hack["sut"] = Application.Attach(sut_identifier)  # noqa: F841
                return True
            except WhiteException:
                return False

        Wait.until_true(search_application, timeout, exception_message)

        return hack["sut"]
    def attach_application_by_id(self, sut_id):
        """Attaches a running application by process id.

        ``sut_id`` is the application process id.

        Example:
        | Attach Application By Id | 12188 |
        """
        self.state.app = Application.Attach(int(sut_id))
    def attach_application_by_name(self, sut_name):
        """Attaches a running application by name.

        ``sut_name`` is the name of the process.

        Example:
        | Attach Application By Name | UIAutomationTest |
        """
        self.state.app = Application.Attach(sut_name)
Exemple #4
0
    def attach_application_by_id(self, sut_id):
        """ Attaches to a running application by id.

        ``sut_id`` is the application process id.
        """
        self.state.app = Application.Attach(int(sut_id))
Exemple #5
0
    def attach_application_by_name(self, sut_name):
        """ Attaches to a running application by name.

        ``sut_name`` is the application process name.
        """
        self.state.app = Application.Attach(sut_name)
 def search_application():
     try:
         hack["sut"] = Application.Attach(sut_identifier)  # noqa: F841
         return True
     except WhiteException:
         return False