def test_iswindow(self):
        """Make sure the iswindow method returns correct result"""
        self.assertEqual(True, iswindow(self.dlghandle))
        self.assertEqual(True, iswindow(self.edit_handle))

        self.assertEqual(False, iswindow(1))
        self.assertEqual(False, iswindow(sys.maxsize))
        self.assertEqual(False, iswindow(None))
Example #2
0
    def test_iswindow(self):
        """Make sure the iswindow method returns correct result"""
        self.assertEqual(True, iswindow(self.dlghandle))
        self.assertEqual(True, iswindow(self.edit_handle))

        self.assertEqual(False, iswindow(1))
        self.assertEqual(False, iswindow(sys.maxsize))
        self.assertEqual(False, iswindow(None))
    def handle(self):
        """ Find the dialog with the specified title and text.
        Then click at the specified button or send the key string to it to close it.
        """

        # Check if the dialog with the specified text exists or not
        dlg_handle_list = application.findwindows.find_windows(
            self._class_name, self._class_name_re,
            self._parent, self._process,
            self._title, self._title_re,
            self._top_level_only, self._visible_only, self._enabled_only,
            self._best_match, self._handle, self._ctrl_index,
            self._predicate_func, self._active_only
        )

        if (len(dlg_handle_list) == 0):
            return False

        # Yes, get the handle of it
        handle_id = dlg_handle_list[0]

        # Verify if it is a real dialog
        if not(handleprops.iswindow(handle_id)):
            return False

        # Get the handles of the controls
        hwnd = controls.HwndWrapper.HwndWrapper(handle_id)
        child_ctrls_list = hwnd.Children()

        # The dialog is found
        # Now enter the file name to the textbox
        button_ok = False
        for child_obj in child_ctrls_list:
            if child_obj.Class() == "Edit" and child_obj.ControlID() == 1148:
                child_obj.SetText(self.file_path)
                button_ok = True

        if button_ok:
            for child_obj in child_ctrls_list:
                if child_obj.Class() == "Button" and self._button_name == child_obj.WindowText():
                    child_obj.Click()
                    return True

        # Unable to handle the dialog
        return False
Example #4
0
    def test_iswindow(self):
        "Make sure the iswindow method returns correct result"
        self.assertEquals(True, iswindow(self.dlghandle))
        self.assertEquals(True, iswindow(self.edit_handle))

        self.assertEquals(False, iswindow(1))
Example #5
0
    def test_iswindow(self):
        "Make sure the iswindow method returns correct result"
        self.assertEquals(True, iswindow(self.dlghandle))
        self.assertEquals(True, iswindow(self.edit_handle))

        self.assertEquals(False, iswindow(1))
    def handle(self):
        """ Find the dialog with the specified title and text.

        Then click at the specified button or send the key string to it to close it.
        """
        # Check if the dialog with the specified text exists or not
        dlg_handle_list = application.findwindows.find_windows(
            self._class_name, self._class_name_re,
            self._parent, self._process,
            self._title, self._title_re,
            self._top_level_only, self._visible_only, self._enabled_only,
            self._best_match, self._handle, self._ctrl_index,
            self._predicate_func, self._active_only
        )

        if (len(dlg_handle_list) == 0):
            return False

        # Yes, get the handle of it
        handle_id = dlg_handle_list[0]

        # Verify if it is a real dialog
        if not(handleprops.iswindow(handle_id)):
            return False

        # Get the handles of the controls
        hwnd = controls.HwndWrapper.HwndWrapper(handle_id)
        child_ctrls_list = hwnd.Children()

        # Verify the text inside if required
        if len(self._static_text) > 0:
            # Access all the child controls of the dialog
            # and verify the text
            found = False
            for child_obj in child_ctrls_list:
                if child_obj.Class() == "Static" and self._static_text in child_obj.WindowText():
                    found = True
                    break

            if not found:
                return False

        # The dialog is found
        # set the instance's properties
        self._set_properties(handle_id)

        # Now try to close it by clicking on a button
        if len(self._button_name) > 0:
            for child_obj in child_ctrls_list:
                if child_obj.Class() == "Button" and self._button_name == child_obj.WindowText():
                    child_obj.Click()
                    return True

        # Send the key string to the dialog
        if self._key_string:
            hwnd.TypeKeys(self._key_string)
            return True

        # Or click on the sequence of coordinates if required
        if len(self._coords_list):
            for coords in self._coords_list:
                hwnd.ClickInput(coords = coords)

        # Try to click on the X button at the top-right corner as the last resort
        hwnd.Close()

        # Unable to handle the dialog
        return False