Best Python code snippet using lettuce_webdriver_python
NCRs_for_Chris.py
Source: NCRs_for_Chris.py
1#!/usr/bin/env python2from __future__ import print_function3import sys4import csv5import codecs6from eTraveler.clientAPI.connection import Connection7from eTraveler.clientAPI.connection import ETClientAPINoDataException8def get_NCRs(conn, htype='LCA-11021_RTM', component='LCA-11021_RTM-004'):9 rsp = {}10 url_base = 'https://lsst-camera.slac.stanford.edu/eTraveler/exp/LSST-CAMERA/displayActivity.jsp?dataSourceMode=prod&activityId='11 try:12 labels = ['Priority:', 'Mistake:']13 print("Calling getHardwareInstances for hardware type ", htype, " one label") 14 rsp = conn.getHardwareNCRs(htype=htype, experimentSN=component,15 items='children',ncrLabels=labels)16 print("Returned list of NCRs for component ", component)17 entry = 018 # Also write to CSV file19 with open(component + '.csv', 'w') as csvfile:20 fieldnames = ['entry', 'level', 'hardwareType', 'experimentSN',21 'NCRname', 'NCRnumber', 'NCRurl','currentStep',22 'NCRstatus', 'ncrLabels', 'runNumber', 'done', 23 'should_see', 'did_see']24 #, 'NCRtype', 'disposition']25 writer = csv.DictWriter(csvfile, fieldnames=fieldnames)26 writer.writeheader()27 for h in rsp:28 print("\nfor entry ",entry, " NCR# ", h['NCRnumber'])29 for k in h:30 print('Value for key ', k, ' is ',h[k])31 32 h['entry'] = entry33 h['NCRurl'] = url_base + str(h['NCRnumber'])34 del h['exceptionId']35 del h['hardwareId']36 runrsp = conn.getManualRunResults(run=h['runNumber'])37 steps = runrsp['steps']38 for s in steps: print(s)39 40 # The remaining fields only get filled in if the NCR was far enough along41 h['should_see'] = 'N/A'42 h['did_see'] = 'N/A'43 #h['NCRtype'] = 'N/A'44 #h['disposition'] = 'N/A'45 if 'NCR_A_Description' in steps:46 descr = steps['NCR_A_Description']47 h['should_see'] = descr['Should_have_been_seen']['value']48 h['did_see'] = descr['Was_seen']['value']49 if type(h['should_see']) != type(""):50 #print("Offending text: ")51 #print(h['should_see'])52 try:53 h['should_see'] = h['should_see'].encode('ascii', errors='replace')54 except:55 h['should_see'] = '(ascii encoding error)'56 if type(h['did_see']) != type(""):57 #print("Offending text: ")58 #print(h['did_see'])59 60 try:61 h['did_see'] = h['did_see'].encode('ascii', errors='replace')62 except:63 h['did_see'] = '(ascii encoding error)'64 65 66 #if 'NCR_Simple' in steps: 67 # h['NCRtype'] = 'Simple'68 # h['disposition'] = steps['NCR_Simple']['Provide_the_disposition']['value']69 #if 'NCR_C_Final_disposition' in steps:70 # h['disposition'] = steps['NCR_C_Final_disposition']['Final_disposition']['value']71 # h['NCRtype'] = 'Complex'72 73 writer.writerow(h)74 entry +=175 sys.exit(0)76 except ETClientAPINoDataException as msg:77 print('No data exception: ',msg)78 sys.exit(1)79 except Exception as msg:80 print('Operation failed with exception: ')81 print(msg)82 sys.exit(1)83 84if __name__ == '__main__':85 import argparse86 parser = argparse.ArgumentParser(description="""87 Generate csv of NCR info for specified component88 """)89 parser.add_argument('--component','-c', help='experimentSN',90 default='LCA-11021_RTM-004')91 parser.add_argument('--htype', '-ht', help='hardware type',92 default='LCA-11021_RTM')93 myConn = Connection('jrb', 'Prod', debug=False, prodServer=True, 94 appSuffix='')95 args = parser.parse_args()96 #get_NCRs(myConn, component='LCA-11021_RTM-005')97 print("Arguments:")98 adict = vars(args)99 print(adict)...
find_mismatched_comments.py
Source: find_mismatched_comments.py
1#!/usr/bin/env python2# -*- coding: utf-8 -*-3import pywikibot, re, sys, codecs, argparse4import blib5from blib import getparam, rmparam, tname, pname, msg, site6def process_text_on_page(index, pagetitle, text):7 def pagemsg(txt):8 msg("Page %s %s: %s" % (index, pagetitle, txt))9 text_and_comments = re.split("(<!--|-->)", text)10 grouped_text_and_comments = []11 for i in range(1, len(text_and_comments), 2):12 preceding_text = text_and_comments[i - 1][-20:].replace("\n", r"\n")13 following_text = text_and_comments[i + 1][:20].replace("\n", r"\n")14 grouped_text_and_comments.append((preceding_text + text_and_comments[i] + following_text, text_and_comments[i]))15 num_open_comments = len([x for x in grouped_text_and_comments if x[1] == "<!--"])16 num_close_comments = len([x for x in grouped_text_and_comments if x[1] == "-->"])17 warnings = []18 if num_open_comments != num_close_comments:19 warnings.append("%s open comments but %s close comments" % (num_open_comments, num_close_comments))20 for i, (near_text, comment) in enumerate(grouped_text_and_comments):21 should_see = "<!--" if i % 2 == 0 else "-->"22 if comment != should_see:23 warnings.append("Saw <nowiki>%s</nowiki> at position %s but expected <nowiki>%s</nowiki>, near text '<nowiki>%s</nowiki>'" %24 (comment, i, should_see, near_text))25 break26 if comment == "<!--" and i == len(grouped_text_and_comments) - 1:27 warnings.append("Saw final unclosed <nowiki>%s</nowiki> at position %s, near text '<nowiki>%s</nowiki>'" %28 (comment, i, near_text))29 break30 if warnings:31 pagemsg("WARNING: %s" % "; ".join(warnings))32parser = blib.create_argparser("Find mismatched comments",33 include_pagefile=True, include_stdin=True)34args = parser.parse_args()35start, end = blib.parse_start_end(args.start, args.end)...
steps.py
Source: steps.py
...5@when('I add a new resource')6def click_link_text(text):7 text = "Add new resource"8@when('I see "Name:"')9def should_see(text):10 text = "Name:"11@when('I enter "test" in "box"')12def click_element(element):13 element = "id_name"14@when('I fill in "Description Name" with "BDD TEST" ')15def should_see(context, text):16 context.execute_steps()17@when('I fill in "Url" with "BDD TEST" ')18def should_see(context, text):19 context.execute_steps('')20@when('I press "Submit"" ')21def step_impl(context):...
Check out the latest blogs from LambdaTest on this topic:
API (Application Programming Interface) is a set of definitions and protocols for building and integrating applications. It’s occasionally referred to as a contract between an information provider and an information user establishing the content required from the consumer and the content needed by the producer.
There is just one area where each member of the software testing community has a distinct point of view! Metrics! This contentious issue sparks intense disputes, and most conversations finish with no definitive conclusion. It covers a wide range of topics: How can testing efforts be measured? What is the most effective technique to assess effectiveness? Which of the many components should be quantified? How can we measure the quality of our testing performance, among other things?
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
Many theoretical descriptions explain the role of the Scrum Master as a vital member of the Scrum team. However, these descriptions do not provide an honest answer to the fundamental question: “What are the day-to-day activities of a Scrum Master?”
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!