How to use parse_control method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...15 for child in elem:16 if child.tail:17 ans.append(child.tail)18 return ''.join(ans)19def parse_control(elem, parent_of, default_type='text'):20 attrs = dict(elem.attrib)21 label_elem = parent_of(elem, 'label')22 if label_elem is not None:23 lt = label_text(label_elem)24 if lt:25 attrs["__label"] = lt26 ctype = attrs.get('type') or default_type27 return ctype, attrs.get('name'), attrs28def parse_input(elem, parent_of, *a):29 return parse_control(elem, parent_of)30def parse_button(elem, parent_of, *a):31 ctype, name, attrs = parse_control(elem, parent_of, default_type='submit')32 ctype += 'button'33 return ctype, name, attrs34def parse_option(elem, parent_of, attrs_map):35 ctype, name, attrs = parse_control(elem, parent_of)36 og = parent_of(elem, 'optgroup')37 contents = (elem.text or '').strip()38 attrs['contents'] = contents39 attrs['value'] = attrs.get('value', contents)40 attrs['label'] = attrs.get('label', contents)41 if og is not None and og.get('disabled') is not None:42 attrs['disabled'] = 'disabled'43 sel = parent_of(elem, 'select')44 if sel is None:45 raise SkipControl()46 attrs['__select'] = sel = attrs_map[sel]['__select']47 return 'select', sel.get('name'), attrs48def parse_textarea(elem, parent_of, *a):49 ctype, name, attrs = parse_control(elem, parent_of)50 ctype = 'textarea'51 attrs['value'] = normalize_line_endings(elem.text or u'')52 return ctype, name, attrs53def parse_select(elem, parent_of, *a):54 ctype, name, attrs = parse_control(elem, parent_of)55 ctype = 'select'56 return ctype, name, {'__select': attrs}57def parse_forms(root, base_url, request_class=None, select_default=False):58 if request_class is None:59 request_class = Request60 global_form = HTMLForm(base_url)61 forms, labels = [], []62 form_elems = []63 form_id_map = {}64 all_elems = tuple(65 e for e in root.iter('*') if isinstance(e.tag, basestring))66 parent_map = {c: p for p in all_elems for c in p}67 id_to_labels = defaultdict(list)68 for e in all_elems:...

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:


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

Run autotest 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?