コード例 #1
0
 def _moveToElement(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     DriverBaseWeb.move_to_element(element)
コード例 #2
0
 def _addCookie(self, action):
     '''
     :param action:
     :return:
     '''
     key = self._getParms(action, 0)
     DriverBaseWeb.add_cookie(key)
コード例 #3
0
 def _clear(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     DriverBaseWeb.clear(element)
コード例 #4
0
 def _contextClick(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     DriverBaseWeb.context_click(element)
コード例 #5
0
 def _switchToFrame(self, action):
     '''
     :param action:
     :return:
     '''
     frame_reference = self._getParms(action)
     DriverBaseWeb.switch_to_frame(frame_reference)
コード例 #6
0
 def _openUrl(self, action):
     '''
     :param action:
     :return:
     '''
     url = self._getParms(action, 0)
     DriverBaseWeb.open_url(url)
コード例 #7
0
 def _submit(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     DriverBaseWeb.submit(element)
コード例 #8
0
 def _switchToWindow(self, action):
     '''
     :param action:
     :return:
     '''
     handle = self._getParms(action)
     DriverBaseWeb.switch_to_window(handle)
コード例 #9
0
 def _holdClick(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     DriverBaseWeb.click_and_hold(element)
コード例 #10
0
 def _doubleClick(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     DriverBaseWeb.double_click(element)
コード例 #11
0
 def _deleteCookie(self, action):
     '''
     :param action:
     :return:
     '''
     key = self._getParms(action, 0)
     DriverBaseWeb.delete_cookie(key)
コード例 #12
0
 def _moveByOffset(self, action):
     '''
     :param action:
     :return:
     '''
     xoffset = self._getParms(action, 0)
     yoffset = self._getParms(action, 1)
     DriverBaseWeb.move_by_offset(float(xoffset), float(yoffset))
コード例 #13
0
 def _dragDrop(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action, 0)
     target = self._getElement(action, 1)
     DriverBaseWeb.drag_and_drop(element, target)
コード例 #14
0
 def _setWindowPosition(self, action):
     '''
     :param action:
     :return:
     '''
     x = self._getParms(action, 0)
     y = self._getParms(action, 1)
     DriverBaseWeb.set_window_position(float(x), float(y))
コード例 #15
0
ファイル: run_case.py プロジェクト: nerocat535/fasttest
 def setUp(self):
     if self.skip:
         self.skipTest('skip')
     if Var.re_start:
         if Var.driver != 'selenium':
             DriverBaseApp.launch_app(None)
         else:
             DriverBaseWeb.createSession()
コード例 #16
0
 def _setWindowSize(self, action):
     '''
     :param action:
     :return:
     '''
     width = self._getParms(action, 0)
     height = self._getParms(action, 0)
     DriverBaseWeb.set_window_size(float(width), float(height))
コード例 #17
0
ファイル: run_case.py プロジェクト: nerocat535/fasttest
 def tearDown(self):
     if Var.re_start:
         try:
             if Var.driver != 'selenium':
                 DriverBaseApp.close_app(None)
             else:
                 DriverBaseWeb.quit()
         except:
             pass
コード例 #18
0
 def _moveToElementWithOffset(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     xoffset = self._getParms(action, 1)
     yoffset = self._getParms(action, 2)
     DriverBaseWeb.move_to_element_with_offset(element, float(xoffset),
                                               float(yoffset))
コード例 #19
0
 def _dragDropByOffset(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     xoffset = self._getParms(action, 1)
     yoffset = self._getParms(action, 2)
     DriverBaseWeb.drag_and_drop_by_offse(element, float(xoffset),
                                          float(yoffset))
コード例 #20
0
 def _sendKeys(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     text_list = []
     if len(action.parms) == 2:
         text_list.append(self._getParms(action, 1))
     elif len(action.parms) == 3:
         text_list.append(self._getParms(action, 1))
         text_list.append(self._getParms(action, 2))
     else:
         raise TypeError('missing 1 required positional argument')
     DriverBaseWeb.send_keys(element, text_list)
コード例 #21
0
    def start(self):

        if not self._suite:
            return None
        # 组装启动参数
        log_info(
            '******************* analytical desired capabilities *******************'
        )
        Var.desired_capabilities = Dict({
            'driver': Var.driver.lower(),
            'timeOut': Var.time_out,
            'desired': Var.desired_caps,
            'index': self._index,
            'root': self._root
        })
        # 启动服务
        if Var.driver != 'selenium':
            server = ServerUtilsApp(Var.desired_capabilities)
            Var.instance = server.start_server()
        elif not Var.re_start:
            server = ServerUtilsWeb(Var.desired_capabilities)
            Var.instance = server.start_server()
            DriverBaseWeb.init()
        else:
            server = None
        # 用例运行
        suite = unittest.TestSuite(tuple(self._suite))
        runner = TestRunner()
        runner.run(suite)

        # 结束服务
        if Var.driver != 'selenium':
            server.stop_server()
        elif not Var.re_start:
            server.stop_server(Var.instance)

        # 打印失败结果
        if Var.all_result:
            if Var.all_result.errorsList:
                log_info(' Error case:')
            for error in Var.all_result.errorsList:
                log_error(error, False)

            if Var.all_result.failuresList:
                log_info(' Failed case:')
            for failure in Var.all_result.failuresList:
                log_error(failure, False)
        return Var.all_result
コード例 #22
0
 def _getText(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     return DriverBaseWeb.get_text(element)
コード例 #23
0
    def _getElement(self, action, index=0):
        '''
        :param action:
        :return:
        '''
        parms = action.parms
        if len(parms) <= index or not len(parms):
            raise TypeError(
                'missing {} required positional argument'.format(index + 1))
        if isinstance(parms[index], WebElement):
            element = parms[index]
        elif isinstance(parms[index], str):
            if not re.match(
                    r'^(id|name|class|tag_name|link_text|partial_link_text|xpath|css_selector)\s*=.+',
                    parms[index].strip(), re.I):
                raise TypeError('input parameter format error:{}'.format(
                    parms[index]))
            key = parms[index].split('=', 1)[0].strip()
            value = parms[index].split('=', 1)[-1].strip()
            element = DriverBaseWeb.get_element(key, value, Var.time_out)
        else:
            raise TypeError('the parms type must be: WebElement or str')

        if not element:
            raise Exception("Can't find element: {}".format(parms[index]))
        return element
コード例 #24
0
 def _getTagName(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     return DriverBaseWeb.get_tag_name(element)
コード例 #25
0
 def _getCookie(self, action):
     '''
     :param action:
     :return:
     '''
     key = self._getParms(action)
     return DriverBaseWeb.get_cookie(key)
コード例 #26
0
 def _getLocation(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     return DriverBaseWeb.get_location(element)
コード例 #27
0
 def _getSize(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     return DriverBaseWeb.get_size(element)
コード例 #28
0
 def _isEnabled(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     return DriverBaseWeb.is_enabled(element)
コード例 #29
0
 def _isDisplayed(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     return DriverBaseWeb.is_displayed(element)
コード例 #30
0
 def _getCssProperty(self, action):
     '''
     :param action:
     :return:
     '''
     element = self._getElement(action)
     css_value = self._getParms(action, 1)
     return DriverBaseWeb.get_css_property(element, css_value)