How to use _find_scripts method in localstack

Best Python code snippet using localstack_python

input.py

Source:input.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-23import os4import re56from automationsys import Configure7from automation.performance.actor import Actor8from automation.cast.assistant import Locator910class InputComponent(Actor):1112 def __init__(self, p_selector,p_type, p_id, p_class, p_xpath, p_name, p_tag, p_parameters, p_data_model=None):13 Actor.__init__(self, p_selector,p_type, p_id, p_class, p_xpath, p_name, p_tag)14 print ("init input comp, name -> " + p_name)15 self._selector = p_selector16 self._act_time = None17 self._type = None18 self._value = None19 self._comp = None20 self._data_model = p_data_model21 self._dataBinding = False22 self._databinding_pattern = re.compile(r'\{\{[\w\d]+\}\}')23 self._databinding_key = None24 self.setProperties(p_parameters)25 26 class Text(object):2728 def __init__(self, p_comp):29 self._component = p_comp3031 def input(self, p_value):32 if self._component:33 print ("Input send key: " + p_value)34 for com in self._component:35 com.clear()36 com.send_keys(p_value)3738 class RichText(object):3940 def __init__(self, p_comp):41 pass4243 class Select(object):4445 def __init__(self, p_name,p_tag,p_class,p_id):46 self._name = "'"+p_name+"'" if p_name else "null"47 self._tag = "'"+p_tag+"'" if p_tag else "null"48 self._class = "'"+p_class+"'" if p_class else "null"49 self._id = "'"+p_id+"'" if p_id else "null"5051 self._find_script = open(Configure.get_application_root_dir()+"/js/findelements_min.js")52 self._select_script = open(Configure.get_application_root_dir()+"/js/select_min.js")53 self._find_scripts = None54 self._select_scripts = None55 if self._find_script:56 self._find_scripts = self._find_script.readline()57 if self._select_script:58 self._select_scripts = self._select_script.readline()5960 def input(self, p_value):61 func = u"select('"+p_value+"',"+self._name+","+self._tag+","+self._class+","+self._id+");"62 print (func)63 Configure.get_chrome_webdriver().execute_script(self._find_scripts.decode("utf-8")+" "+self._select_scripts.decode("utf-8")+" "+func);6465 def do(self, p_location=None): 66 lines = self.getData()67 print ("Input get data: "+lines)6869 if self._type == "text":70 comp = self.getComponent()71 text = self.Text(comp)72 text.input(lines)73 return7475 if self._type == "select":76 select = self.Select(p_name=self.getName(),p_tag=self.getTag(),p_class=self.getClass(),p_id=self.getID())77 select.input(lines)78 return7980 def duration(self):81 return self._act_time8283 def getProperty(self, p_name): 84 pass8586 def getData(self):87 if self._dataBinding:88 return self._data_model[self._databinding_key]89 else:90 return self._value9192 def setProperties(self, p_parameters): 93 duration = p_parameters["duration"] if p_parameters.has_key("duration") else None94 type = p_parameters["type"] if p_parameters.has_key("type") else None95 contents = p_parameters["contents"] if p_parameters.has_key("contents") else ""9697 m = self._databinding_pattern.match(contents)98 if m:99 self._dataBinding = True100 self._databinding_key = contents[2:-2]101 else:102 self._value=contents103104 if duration:105 self._act_time = int(duration)106 self._type = type ...

Full Screen

Full Screen

setup.py

Source:setup.py Github

copy

Full Screen

...15 """Import requirements from an external file in compatible format with setuptools."""16 with open(file, 'rt') as requirements_file:17 requirements = [requirement.strip() for requirement in requirements_file.readlines()]18 return requirements19def _find_scripts(directory: str) -> list:20 """Locate scripts and provide endpoint names compatible with setuptools."""21 scripts = []22 for abs_path in glob.glob(os.path.join(MODULE_DIR, f'{directory}/*.py')):23 filename = os.path.basename(abs_path).rstrip('.py')24 if not filename.startswith('__'):25 scripts.append('{} = defender.scripts.{}:main'.format(filename, filename))26 return scripts27PACKAGE_DATA = {28 '': [29 *_find_files('defender/demodata'),30 *_find_files('defender/html')31 ]32}33PACKAGES = setuptools.find_packages(MODULE_DIR, include=['defender*'], exclude=['*test', '*benchmarks'])34setuptools.setup(35 name='defender',36 version='0.1.0',37 url='http://solaristudios.com/defender',38 license='Apache Software License',39 author='David Fritz',40 tests_require=['pytest'],41 install_requires=_find_requirements(REQUIREMENTS_FILE),42 description='Security and Defense Device Manager with REST API',43 packages=['defender'],44 platforms='Linux',45 python_requires='>=3.6',46 entry_points={47 'console_scripts': _find_scripts('defender/scripts')48 },49 classifiers=[50 'Programming Language :: Python',51 'Development Status :: 4 - Beta',52 'Natural Language :: English',53 'Environment :: Console',54 'Environment :: Web Environment',55 'Intended Audience :: System Administrators',56 'License :: OSI Approved :: Apache Software License',57 'Operating System :: POSIX',58 'Topic :: Office/Business',59 'Topic :: Software Development :: Libraries :: Application Frameworks',60 ],61)

Full Screen

Full Screen

resolver.py

Source:resolver.py Github

copy

Full Screen

2from pathlib import Path3from collections import namedtuple4ScriptLocator = namedtuple('ScriptLocator', 'name path')5def find_script_with_name(name: str) -> str:6 files_with_name = list(filter(lambda x: x.name == name, _find_scripts()))7 _verify_matching_scripts(name, files_with_name)8 return files_with_name[0].path9def _verify_matching_scripts(script_name, scripts):10 scripts_count = len(scripts)11 if (scripts_count == 0):12 raise InvalidScriptNameError(script_name)13 elif (scripts_count > 1):14 raise ConflictingScriptNamesError(script_name, scripts)15def _find_scripts():16 scripts_location = os.environ['SCRIPTER_SCRIPTS']17 script_paths = list(filter(_is_script, _all_files_under_folder(scripts_location)))18 return map(_script_locator_for_path, script_paths)19def _script_locator_for_path(path):20 return ScriptLocator(path.stem, path)21def _all_files_under_folder(folderPath: str):22 return [ Path(os.path.join(root, fileName)) for root, directories, files in os.walk(folderPath) for fileName in files ]23def _is_script(path: Path):24 return path.suffix in ['.ps1', '.py', '.js', '.sh']25class InvalidScriptNameError(Exception):26 def __init__(self, filename):27 super()28 self.filename = filename29class ConflictingScriptNamesError(Exception):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful