コード例 #1
0
ファイル: ldtpkw.py プロジェクト: Python3pkg/LDTPLibrary
    def mouse_right_click(self, window_name, object_name):
        """
        Mouse right click on an object.

        @param window_name: Window name to look for, either full name,
        LDTP's name convention, or a Unix glob.

        @type window_name: string

        @param object_name: Object name to look for, either full name,
        LDTP's name convention, or a Unix glob. Or menu heirarchy

        @type object_name: string

        @return: 1 on success.

        @rtype: integer
        """
        try:
            self._info("Mouse right click on an object")
            return ldtp.mouserightclick(window_name, object_name)
        except LdtpExecutionError as e:
            raise LdtpExecutionError(e.message)
コード例 #2
0
ファイル: ldtpkw.py プロジェクト: Python3pkg/LDTPLibrary
    def grab_focus(self, window_name, object_name):
        """
        Grab focus.

        @param window_name: Window name to look for, either full name,
        LDTP's name convention, or a Unix glob.

        @type window_name: string

        @param object_name: Object name to look for, either full name,
        LDTP's name convention, or a Unix glob.

        @type object_name: string

        @return: 1 on success.

        @rtype: integer
        """
        try:
            self._info('grab focus (%s, %s)' % (window_name, object_name))
            return ldtp.grabfocus(window_name, object_name)
        except LdtpExecutionError:
            raise LdtpExecutionError('grab focus object failed.')
コード例 #3
0
ファイル: ldtpkw.py プロジェクト: skyhack1212/LDTPLibrary
    def wait_till_gui_exist(self,
                            window_name,
                            object_name='',
                            gui_time_out=30,
                            state=''):
        """
        Wait till a window or component exists.

        :param window_name:  Window name to look for, either full name,
        LDTP's name convention, or a Unix glob.

        @type window_name: string

        :param object_name: Object name to look for, either full name,
        LDTP's name convention, or a Unix glob.

        @type window_name: string

        :param gui_time_out: Wait timeout in seconds.

        @type gui_time_out: integer

        :param state: Object state used only when object_name is provided.

        @type state: string

        :return: 1 if GUI was found, 0 if not.

        @rtype: integer
        """
        try:
            self._info("wait till a window or component exists. [%s, %s, %d]" %
                       (window_name, object_name, gui_time_out))
            return ldtp.waittillguiexist(window_name, object_name,
                                         gui_time_out, state)
        except LdtpExecutionError:
            raise LdtpExecutionError("exec ldtp.waittillguiexist failed")
コード例 #4
0
    def uncheck_row(self, window_name, object_name, row_index, column=0):
        """
        Check row

        @param window_name: Window name to type in, either full name,
        LDTP's name convention, or a Unix glob.
        @type window_name: string
        @param object_name: Object name to type in, either full name,
        LDTP's name convention, or a Unix glob.
        @type object_name: string
        @param row_index: Row index to get
        @type row_index: integer
        @param column: Column index to get, default value 0
        @type column: integer

        @return: 1 on success.
        @rtype: integer
        """
        try:
            self._info("uncheck row at (%s, %s, %d)" %
                       (window_name, object_name, row_index))
            return ldtp.uncheckrow(window_name, object_name, row_index, column)
        except LdtpExecutionError as e:
            raise LdtpExecutionError(str(e))
コード例 #5
0
ファイル: ldtpkw.py プロジェクト: skyhack1212/LDTPLibrary
    def gui_exist(self, window_name, object_name=''):
        """
        [关键字概要] 检查窗口或者组件对象是否存在

        :@参数 window_name: 窗口名称

        :@参数 object_name: 对象名称

        :@返回值: 存在返回 1,不存在返回 0

        Examples:

        |  *Test Cases*  |        *Action*       |    *Argument*   |    *Argument*   |
        |  Example_Test  |       GUI Exist       |  ${window_name} |                 |
        |                |       GUI Exist       |  ${window_name} |  ${object_name} |

        """
        try:
            self._info("gui exist (%s, %s)" % (window_name, object_name))
            return ldtp.guiexist(window_name, object_name)
        except LdtpExecutionError:
            raise LdtpExecutionError(
                "gui exist failed, please check if the input parameters are correct. "
            )
コード例 #6
0
ファイル: ldtpkw.py プロジェクト: skyhack1212/LDTPLibrary
    def list_sub_menus(self, window_name, object_name):
        """
        List children of menu item

        @param window_name: Window name to look for, either full name,
        LDTP's name convention, or a Unix glob.

        @type window_name: string

        @param object_name: Object name to look for, either full name,
        LDTP's name convention, or a Unix glob. Or menu heirarchy

        @type object_name: string

        @return: menu item in list on success.

        @rtype: list
        """
        try:
            self._info("list children of menu item (%s-->%s)" %
                       (window_name, object_name))
            return ldtp.listsubmenus(window_name, object_name)
        except LdtpExecutionError as e:
            raise LdtpExecutionError(e.message)
コード例 #7
0
ファイル: ldtpkw.py プロジェクト: skyhack1212/LDTPLibrary
    def get_combo_value(self, window_name, object_name):
        """
        Get current selected combobox value

        @param window_name: Window name to type in, either full name,
        LDTP's name convention, or a Unix glob.

        @type window_name: string

        @param object_name: Object name to type in, either full name,
        LDTP's name convention, or a Unix glob.

        @type object_name: string

        @return: selected item on success, else LdtpExecutionError on failure.

        @rtype: string
        """
        try:
            self._info("Get current selected combobox value (%s-->%s)" %
                       (window_name, object_name))
            return ldtp.getcombovalue(window_name, object_name)
        except LdtpExecutionError as e:
            raise LdtpExecutionError(e.message)
コード例 #8
0
    def does_row_exist(self, window_name, object_name, row_text,
                       partial_match=False):
        """
        Verify table cell value with given text

        @param window_name: Window name to type in, either full name,
        LDTP's name convention, or a Unix glob.
        @type window_name: string
        @param object_name: Object name to type in, either full name,
        LDTP's name convention, or a Unix glob.
        @type object_name: string
        @param row_text: Row text to match
        @type row_text: string
        @param partial_match: Find partial match strings
        @type partial_match:boolean

        @return: 1 on success 0 on failure.
        @rtype: integer
        """
        try:
            self._info("Does row exist (%s, %s, %s)" % (window_name, object_name, row_text))
            return ldtp.doesrowexist(window_name, object_name, row_text, partial_match)
        except LdtpExecutionError as e:
            raise LdtpExecutionError(e.message)
コード例 #9
0
    def request(self, host, handler, request_body, verbose=0):
        # issue XML-RPC request
        retry_count = 1
        while True:
            try:
                if _python26:
                    # Noticed this in Hutlab environment (Windows 7 SP1)
                    # Activestate python 2.5, use the old method
                    return xmlrpclib.Transport.request(self,
                                                       host,
                                                       handler,
                                                       request_body,
                                                       verbose=verbose)
                if not _python3:
                    # Follwing implementation not supported in Python <= 2.6
                    h = self.make_connection(host)
                    if verbose:
                        h.set_debuglevel(1)

                    self.send_request(h, handler, request_body)
                    self.send_host(h, host)
                    self.send_user_agent(h)
                    self.send_content(h, request_body)
                else:
                    h = self.send_request(host, handler, request_body,
                                          bool(verbose))

                response = h.getresponse()

                if response.status != 200:
                    raise xmlrpclib.ProtocolError(host + handler,
                                                  response.status,
                                                  response.reason,
                                                  response.msg.headers)

                payload = response.read()
                parser, unmarshaller = self.getparser()
                parser.feed(payload)
                parser.close()

                return unmarshaller.close()
            except SocketError as e:
                if ((_ldtp_windows_env and e[0] == 10061) or \
                        (hasattr(e, 'errno') and (e.errno == 111 or \
                                                      e.errno == 61 or \
                                                      e.errno == 146))) \
                        and 'localhost' in host:
                    if hasattr(self, 'close'):
                        # On Windows XP SP3 / Python 2.5, close doesn't exist
                        self.close()
                    if retry_count <= 6:
                        retry_count += 1
                        if not _ldtp_windows_env:
                            sigusr1 = signal.signal(signal.SIGUSR1,
                                                    self._handle_signal)
                            sigalrm = signal.signal(signal.SIGALRM,
                                                    self._handle_signal)
                            sigchld = signal.signal(signal.SIGCHLD,
                                                    self._handle_signal)
                        self._spawn_daemon()
                        if _ldtp_windows_env:
                            time.sleep(5)
                        else:
                            signal.alarm(15)  # Wait 15 seconds for ldtpd
                            signal.pause()
                            # restore signal handlers
                            signal.alarm(0)
                            signal.signal(signal.SIGUSR1, sigusr1)
                            signal.signal(signal.SIGALRM, sigalrm)
                            signal.signal(signal.SIGCHLD, sigchld)
                        continue
                    else:
                        raise
                # else raise exception
                raise
            except xmlrpclib.Fault as e:
                if hasattr(self, 'close'):
                    self.close()
                if e.faultCode == ERROR_CODE:
                    raise LdtpExecutionError(e.faultString.encode('utf-8'))
                else:
                    raise e