Ejemplo n.º 1
0
def abrir_navegador(url):
    logger.info(url, also_console=True)
    selenium_lib = BuiltIn().get_library_instance("SeleniumLibrary")
    browser = selenium_lib._current_browser()
    list_prod = browser.find_element_by_class_name('productos')
    for prod in list_prod:
        logger.console(prod)
Ejemplo n.º 2
0
def kw(kwname, *args):
    if gv.pythonmode:
        t = globals().keys()
        t.sort()
        if kwname in globals().keys():
            if kwname.lower() in ['log']:
                builtin = BuiltIn.BuiltIn()
                return builtin.run_keyword(kwname, *args)
            else:
                return globals()[kwname](*args)
    else:
        builtin = BuiltIn.BuiltIn()
        return builtin.run_keyword(kwname, *args)
Ejemplo n.º 3
0
class common:
    def __init__(self):
        self.goto_case = self.load_goto_table('gotocase')
        self.goto_page = self.load_goto_table('gotopage')
    
    def load_goto_table(self,name):
        pk_file = open(name, 'rb')
        data1 = pickle.load(pk_file)
        return data1
    
    def goto_test_case_page(self):
        case = BuiltIn.BuiltIn().get_variable_value('${TEST NAME}')
        act = self.goto_case[case]
        for a in act:
            BuiltIn.BuiltIn().run_keyword(a.keyword,*a.params[0:])
Ejemplo n.º 4
0
    def start_parallel_test(self, test_name, *arguments):
        """Starts executing test with given `test_name` and `arguments`.

        `arguments` is a list of Robot Framework command line arguments passed to
        the started test execution. It should not include data source. Use
        `Set Data Source For Parallel Tests` keyword for setting the data
        source. Additional arguments can also be set in library import and with
        `Add Arguments For Parallel Tests` keyword.

        Returns a process object that represents this execution.

        Example:
        | Set Data Source For Parallel Tests | MySuite.txt |
        | Start Parallel Test | Test From My Suite |
        | Set Data Source For Parallel Tests | MyFriendsSuite.txt |
        | Start Parallel Test | Test From My Friends Suite |
        | Wait All Parallel Tests |
        """
        if self._data_source is None:
            self._data_source = BuiltIn.BuiltIn().replace_variables(
                '${SUITE_SOURCE}')
        process = _ParaRobo(test_name, self._data_source,
                            self._arguments + list(arguments))
        process.run(self._script)
        self._processes.append(process)
        return process
Ejemplo n.º 5
0
 def run(self):
     pkts = sniff(store=1,
                  prn=self.sniff_callback,
                  timeout=self.timeout,
                  stop_filter=self.stop_callback,
                  iface=self.host_lan_iface)
     casename = BuiltIn.BuiltIn().get_variable_value('${TEST NAME}')
     pcapfilename = lan_config_pcap_dir + casename + '.pcap'
     wrpcap(pcapfilename, pkts)
Ejemplo n.º 6
0
 def __init__(self, test, data_source, arguments):
     self.test = test
     self._data_source = data_source
     self._args = arguments
     self._built_in = BuiltIn.BuiltIn()
     id = self._create_id()
     self._output = 'output_%s.xml' % id
     self._log = 'log_%s.html' % id
     self._output_dir = self._built_in.replace_variables("${OUTPUT DIR}")
     self._monitor_out = os.path.join(self._output_dir,
                                      'monitor_%s.txt' % id)
Ejemplo n.º 7
0
def getSuiteSrcDir():
    from robot.api import logger as log
    builtin = BuiltIn.BuiltIn()
    srcPath = builtin.get_variable_value('${SUITE SOURCE}')
    if os.path.isfile(srcPath):
        srcDir = os.path.dirname(srcPath)
    elif os.path.isdir(srcPath):
        srcDir = srcPath
    else:
        log.error("Suite source directory not found; src={0}".format(srcPath))
        srcDir = ''
    return srcDir
Ejemplo n.º 8
0
 def append(self, kw_name, *args):
     from robot.libraries import BuiltIn
     builtin = BuiltIn.BuiltIn()
     item = KeywordItem()
     item.name = kw_name
     item.args = list(args)
     try:
         result = builtin.run_keyword(kw_name, *args)
         item.status = 'PASS'
         item.result = result
     except Exception, e:
         item.status = 'FAILED'
         item.result = e
Ejemplo n.º 9
0
 def web_model(self):
     if self.model == "ride":
         path = os.getcwd()
     else:
         path = os.path.abspath('..')
     Verify = BuiltIn._Verify()
     driver = get_driver()
     class_dict = dict()
     arg_dic = {}
     for i in range(len(self.data_resouce)):
         api, num = split_input_arg(self.data_resouce[i])
         api_name = api.split("_")[0]
         val_path = os.path.join(path, "config", "web", api_name, "data",
                                 "val", "%s.csv" % api)
         elem_path = os.path.join(path, "config", "web", api_name, "data",
                                  "elem", "%s.csv" % api)
         val_data = get_csv_by_no(val_path, num)
         elm_data = get_csv_by_no(elem_path, 1)
         rh_replace_arg_dic(arg_dic, val_data)
         if i == 0:
             script_path = os.path.join(path, "business", "script")
             sys.path.append(script_path)
             lists = os.listdir(script_path)
             for l in lists:
                 mod = __import__(l[:-3])
                 for c in dir(mod):
                     obj_class = getattr(mod, c)
                     class_dict[c] = obj_class
         for cla, obj in class_dict.items():
             obj_method = getattr(obj, api, None)
             if obj_method:
                 obj_method = getattr(
                     obj(driver, self.browser, self.version), api)
                 result = obj_method(val_data, elm_data)
                 if not result.flag:
                     quit_driver(driver)
                     Verify.fail("%s failed,%s" %
                                 (obj_method.__name__, result.msg))
                 rh_replace_arg_dic(result.arg, arg_dic)
                 logger.info("%s success!" % obj_method.__name__)
Ejemplo n.º 10
0
def get_var(var_name):
    m = BuiltIn.BuiltIn()
    return m.get_variable_value(var_name)
import json
from datetime import datetime
from keywords import *
from robot.api import logger
from robot.libraries import BuiltIn
import paramiko
import os
import ntpath
import time
from zipfile import ZipFile

BUILTIN = BuiltIn.BuiltIn()


class WebServiceLibrary(_General_Keywords, _Misc_Keywords,
                        _SiteManagement_Keywords, _OffsetManagement_Keywords,
                        _TableManagement_Keywords, _UserManagement_Keywords,
                        _ECUManagement_Keywords, _Firmware_Keywords,
                        _Database_Keywords, _Quality_Keywords,
                        _Updatewebservice_Keywords, KeywordGroup):

    ROBOT_LIBRARY_VERSION = '0.21'
    ROBOT_LIBRARY_SCOPE = 'GLOBAL'
    ROBOT_LIBRARY_DOC_FORMAT = 'reST'

    def __init__(self):
        self._run_on_failure_keyword = None
        self._running_on_failure_routine = False

        for base in WebServiceLibrary.__bases__:
            base.__init__(self)
Ejemplo n.º 12
0
 def goto_spec_page(self,page):
     act = self.goto_page[page]
     if act == None:
         raise RuntimeError('no exist the '+page+' page')
     for a in act:
         BuiltIn.BuiltIn().run_keyword(a.keyword,*a.params[0:])
Ejemplo n.º 13
0
 def built_in(self) -> robot_built_in.BuiltIn:
     return robot_built_in.BuiltIn()
Ejemplo n.º 14
0
 def select_test_case(self):
     self.clear_test_case_tag()
     for m in self.modules:
         #           if m != 'wan':
         #               continue
         record_kw = []
         record_kw.reverse()
         m_kw = keyword()
         m_kw.keyword = 'Execute JavaScript'
         m_kw.params.append('$.CurrentApp=\"' + m + '\";$.load(\"' + m +
                            '\")')
         BuiltIn.BuiltIn().run_keyword(m_kw.keyword, *m_kw.params[0:])
         record_kw.append(m_kw)
         time.sleep(5)
         innerhtml = BuiltIn.BuiltIn().run_keyword(
             'Execute JavaScript',
             'return window.document.getElementById(\"content_layer\").innerHTML'
         )
         time.sleep(5)
         ava_ele_list = self.get_all_avaulabl_elements(innerhtml)
         bSel = False
         for k, v in ava_ele_list.iteritems():
             if k == 'conntype' and v == 'select':
                 l = BuiltIn.BuiltIn().run_keyword('Get List Items',
                                                   'id=' + k)
                 for item in l:
                     kw = keyword()
                     kw.keyword = 'Select From List By Label'
                     kw.params.append(k)
                     kw.params.append(item)
                     BuiltIn.BuiltIn().run_keyword(kw.keyword,
                                                   *kw.params[0:])
                     if len(record_kw) == 1:
                         record_kw.append(kw)
                     if len(record_kw) == 2:
                         record_kw[1] = kw
                     time.sleep(5)
                     innerhtml = BuiltIn.BuiltIn().run_keyword(
                         'Execute JavaScript',
                         'return window.document.getElementById(\"content_layer\").innerHTML'
                     )
                     time.sleep(5)
                     ava_ele_list = self.get_all_avaulabl_elements(
                         innerhtml)
                     index = BuiltIn.BuiltIn().run_keyword(
                         'Get Value', 'id=' + k)
                     if index == '2':
                         if 'dns_a' in ava_ele_list.keys():
                             del ava_ele_list['dns_a']
                             ava_ele_list['dhcp_dns_a'] = 'input'
                         if 'dns_b' in ava_ele_list.keys():
                             del ava_ele_list['dns_b']
                             ava_ele_list['dhcp_dns_b'] = 'input'
                     if index == '1':
                         if 'dns_a' in ava_ele_list.keys():
                             del ava_ele_list['dns_a']
                             ava_ele_list['pppoe_dns_a'] = 'input'
                         if 'dns_b' in ava_ele_list.keys():
                             del ava_ele_list['dns_b']
                             ava_ele_list['pppoe_dns_b'] = 'input'
                     if index == '3':
                         if 'dns_a' in ava_ele_list.keys():
                             del ava_ele_list['dns_a']
                             ava_ele_list['static_dns_a'] = 'input'
                         if 'dns_b' in ava_ele_list.keys():
                             del ava_ele_list['dns_b']
                             ava_ele_list['static_dns_b'] = 'input'
                     self._select_test_case_and_suite(
                         ava_ele_list.keys(), record_kw)
                 bSel = True
         if bSel != True:
             self._select_test_case_and_suite(ava_ele_list.keys(),
                                              record_kw)
     print str(self.case_goto)
     output = open('gotocase', 'wb')
     pickle.dump(self.case_goto, output)
     output.close()
     print str(self.page_goto)
     output = open('gotopage', 'wb')
     pickle.dump(self.page_goto, output)
     output.close()
Ejemplo n.º 15
0
def case_has_tag(tagname):
    builtin = BuiltIn.BuiltIn()
    tags = kw('create list', '@{Test Tags}')
    return tagname.upper().strip() in [x.upper().strip() for x in tags]
Ejemplo n.º 16
0
def var_exist(varname):
    if not '$' in varname:
        varname = '${%s}' % (varname)
    builtin = BuiltIn.BuiltIn()
    return varname in builtin.get_variables().keys()
Ejemplo n.º 17
0
def spv(varname, value):
    if not '$' in varname:
        varname = '${%s}' % (varname)
    builtin = BuiltIn.BuiltIn()
    builtin.set_suite_variable(varname, value)
Ejemplo n.º 18
0
def pv(varname):
    if not '$' in varname:
        varname = '${%s}' % (varname)
    builtin = BuiltIn.BuiltIn()
    return builtin.get_variables()[varname]