Best Python code snippet using SeleniumBase
Process_VISSIM_Link_Segment_File_FREEWAY.py
...31 }32 )33dict_links = Links.set_index("Link").T.to_dict(orient='list')34# In[5]:35def get_link_attribute(Links, link, attr):36 '''37 Link attribute selector.38 Links: a pandas dataframe contains link attributes39 link: a link40 attr: a string for attr41 42 Sample Link file43 44 {45 1: ['5: Urban-Mixed', 2, 480.73590087890625, 0, 'Connector'],46 2: ['5: Urban-Mixed', 2, 491.6012878417969, 0, 'Connector'],47 3: ['5: Urban-Mixed', 2, 493.388427734375, 0, 'Connector'],48 }49 50 '''51 selector = {52 "LinkType":0,53 "NumLanes":1,54 "Length":2,55 "IsConn":3,56 "FT":457 }58 59 return(Links[link][selector[attr]])60 61# In[6]:62def p2f(x):63 if x!="":64 return float(x.strip('%'))/10065 else:66 return(0.0)67# In[7]:68def read_one_run(FILE_NAME, skiprows=18, filetype="LINK_SEG"):69 if filetype=="LINK_SEG":70 link_seg = pd.read_csv(FILE_NAME, sep=";", skiprows=skiprows, 71 converters={72 0:str(),73 3:float(),74 4:p2f,75 5:float(),76 6:float()77 }78 )79 80 # rename the column81 link_seg = link_seg.rename(columns={ 82 link_seg.columns[0]: "SIMRUN",83 link_seg.columns[3]: "DENSITY",84 link_seg.columns[4]: "DELAYREL",85 link_seg.columns[5]: "SPEED",86 link_seg.columns[6]: "VOLUME"87 })88 return link_seg89# In[8]:90# Read the link segment data91df_link_seg_data = [read_one_run(f) for f in LOADS]92# In[9]:93result_link_seg = pd.concat(df_link_seg_data, keys=np.arange(len(df_link_seg_data))+1, names=['Load']).reset_index().drop("level_1", axis=1)94# In[10]:95# Process ONLY the average data96result_link_seg = result_link_seg[result_link_seg.SIMRUN=="AVG"].reset_index().drop("index", axis=1)97# #### Data Cleaning98# In[13]:99# Set speed = 0 if density = 0 or volume = 0100result_link_seg.loc[(result_link_seg.DENSITY == 0) | (result_link_seg.VOLUME == 0), "SPEED"] = 0.0101# In[14]:102# Split the link evaluation segments103split_link_seg = lambda x: pd.Series([int(i) for i in x.split('-')])104result_link_seg[['LINK','SEGA', 'SEGB']] = result_link_seg['LINKEVALSEGMENT'].apply(split_link_seg)105# In[15]:106# Split the time stamps107split_time_int = lambda x: pd.Series([int(i) for i in x.split('-')])108result_link_seg[['TIMEA','TIMEB']] = result_link_seg['TIMEINT'].apply(split_time_int)109# In[16]:110# Get lane flow and lane density111get_lanes =lambda x: get_link_attribute(dict_links, link=x, attr="NumLanes")112result_link_seg['LANES'] = result_link_seg['LINK'].apply(get_lanes)113result_link_seg['LANEFLOW'] = result_link_seg.VOLUME / result_link_seg.LANES114result_link_seg['LANEDENSITY'] = result_link_seg.DENSITY / result_link_seg.LANES115# In[17]:116# Get facility type117get_ft =lambda x: get_link_attribute(dict_links, link=x, attr="FT")118result_link_seg['FT'] = result_link_seg['LINK'].apply(get_ft)119# save the data for later 120result_link_seg.to_csv("Link_Seg_Data_FREEWAY"+"_"+RUN_NAME+".csv", header=True, index=False)121# In[18]:122# Only freeway but not connectors or ramps123result_link_seg = result_link_seg[result_link_seg.LINK.isin([10, 11, 17])].reset_index(drop=True)124if MULTI_SAMPLE:125 for s in np.arange(10)+1:126 result_link_seg_sample = result_link_seg.sample(10000, random_state=s)127 with open(EST_FILE_NAME+"_"+str(s)+".dat", 'wb') as csvfile:128 csvfile.writelines("VISSIM CAV LINK SEGMENT DATA -- "+RUN_NAME+"\r\n")129 csvfile.writelines(str(result_link_seg_sample.shape[0])+"\t1.000\t1.600\t0.625"+"\r\n")130 writer = csv.writer(csvfile, delimiter='\t', dialect='excel', lineterminator="\r\n")131 for i in result_link_seg_sample.loc[:,["LANEFLOW", "SPEED", "LANEDENSITY"]].values:...
test_index.py
Source: test_index.py
...60 # 3.4 This page shows a logout link, pointing to /logout61 def test_R3_4(self, *_):62 self._login()63 # Verify that profile page shows a logout link pointing to /logout64 self.assert_true(self.get_link_attribute('logout','href'), base_url+'/logout')65 # 3.5 This page lists all available tickets. Information including the quantity of each ticket,66 #the owner's email, and the price, for tickets that are not expired.67 @patch('qa327.backend.get_all_tickets', return_value=[test_ticket])68 def test_R3_5(self, *_):69 self._login()70 # Verify that profile page shows all available tickets71 self.assert_element("#tickets div h4")72 self.assert_text(test_ticket.owner)73 self.assert_text(test_ticket.name)74 self.assert_text(test_ticket.quantity)75 self.assert_text(test_ticket.price)76 self.assert_text(test_ticket.date)77 78 # 3.6 This page contains a form that a user can submit new tickets for sell. Fields: name, quantity, price, expiration date....
Check out the latest blogs from LambdaTest on this topic:
The QA testing profession requires both educational and long-term or experience-based learning. One can learn the basics from certification courses and exams, boot camp courses, and college-level courses where available. However, developing instinctive and practical skills works best when built with work experience.
Ever since the Internet was invented, web developers have searched for the most efficient ways to display content on web browsers.
In general, software testers have a challenging job. Software testing is frequently the final significant activity undertaken prior to actually delivering a product. Since the terms “software” and “late” are nearly synonymous, it is the testers that frequently catch the ire of the whole business as they try to test the software at the end. It is the testers who are under pressure to finish faster and deem the product “release candidate” before they have had enough opportunity to be comfortable. To make matters worse, if bugs are discovered in the product after it has been released, everyone looks to the testers and says, “Why didn’t you spot those bugs?” The testers did not cause the bugs, but they must bear some of the guilt for the bugs that were disclosed.
Xamarin is an open-source framework that offers cross-platform application development using the C# programming language. It helps to simplify your overall development and management of cross-platform software applications.
When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.
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!!