How to use highlight_type method in SeleniumBase

Best Python code snippet using SeleniumBase

Sketch_4.py

Source:Sketch_4.py Github

copy

Full Screen

1import streamlit as st2import pandas as pd3inter_list = ['-']4def selector(start, df_rel, cond, dfr, dfo_ind):5 global selection, gl_config_error6 7 df_cur = dfr[dfr['From'] == start]8 df_cur = df_cur[df_cur['Relation type'].isin(df_rel)]9 df_cur = df_cur[df_cur['Condition'].isin(cond)]10 if len(df_cur) != 0:11 for r in df_cur.iterrows():12 if r[1]['XOR ID'] == '-':13 dfo_ind.loc[start, 'highlight_type'] = 'intermediate'14 15 selector(r[1]['To'], df_rel, cond, dfr, dfo_ind)16 else:17 df_xor = df_cur[df_cur['XOR ID'] == r[1]['XOR ID']]18 default = 'True'19 choice = []20 choice_cond = ''21 for n in df_xor.iterrows():22 if n[1]['Condition'] == '-' and default == 'True':23 choice = n[1]['To']24 elif n[1]['Condition'] in cond and default == 'False':25 gl_config_error = '>>> ERROR:','ambiguous selection. {}-{} with {}-{} for parent object {}'.format(n[1]['To'], n[1]['Condition'], choice, choice_cond,start)26 return27 elif n[1]['Condition'] in cond and default == 'True':28 default = 'False'29 choice = n[1]['To']30 choice_cond = n[1]['Condition']31 else:32 choice = False33 if choice:34 dfo_ind.loc[start, 'highlight_type'] = 'intermediate'35 selector(choice, df_rel, cond, dfr, dfo_ind)36 else:37 selection.append(start)38 else:39 selection.append(start)40 41def set_object_color(st, sel, dfo):42 color_list = []43 44 for i in dfo.iterrows():45 if (i[1]['Object ID'] == st):46 color_list.append('start')47 else:48 if (i[1]['Object ID'] in sel):49 color_list.append('selected')50 51 elif i[1]['highlight_type'] != 'intermediate':52 color_list.append('-')53 else:54 color_list.append('intermediate')55 56 return color_list57 58depth = 059def recur_4x (d, oid, dfr): 60 """61 recursive function to set the x-values for all Objects62 """63 global depth64 if (d < depth):65 depth = d66 67 tdf = dfr[dfr['From'] == oid]68 69 if (len(tdf) > 0):70 for j, r in tdf.iterrows():71 m = recur_4x(d-1, tdf['To'][j], dfr)72 73 if (m < depth):74 depth = m75 return depth76 77header = st.container()78descriptive = st.container()79uploads = st.container()80dropdowns = st.container()81output_table = st.container()82dropdowns2 = st.container()83output_table2 = st.container()84with header:85 st.title('Sketch 4')86 87with descriptive:88 st.markdown(89 """90 ---91 #### Functionality:92 The program automatically adds inverse relations to the list relations.csv.93 94 Note: normal and their inverse relations should not be selected at the same time. 95 This will cause infinite loops of the program.96 97 ---98 """99 )100 101with uploads:102 l_col, r_col = st.columns(2)103 104 objects_u = l_col.file_uploader('Upload Objects', 105 accept_multiple_files = False, 106 type = 'CSV')107 if objects_u is not None:108 df_obj = pd.read_csv(objects_u)109 df_obj = df_obj.fillna("-")110 relations_u = r_col.file_uploader('Upload Relations', 111 accept_multiple_files = False, 112 type = 'CSV')113 if relations_u is not None:114 df_rel = pd.read_csv(relations_u)115 df_rel = df_rel.fillna("-")116 117 df_inv_rel = pd.DataFrame()118 for i, r in df_rel.iterrows():119 irid = r['Relation ID'] + ".i" # inverse relation 'id'120 irfrom = r['To'] # inverse relation 'From'121 irrtype = "(inverse) " + r['Relation type']122 irxor = r['XOR ID']123 irto = r['From']124 ircond = r['Condition']125 irrtt = r['RelTypeType']126 newrel = { "Relation ID": irid, 127 "From": irfrom, 128 "Relation type": irrtype, 129 "XOR ID": irxor, 130 "To": irto, 131 "Condition": ircond, 132 "RelTypeType": irrtt }133 try:134 df_inv_rel = df_inv_rel.append(newrel, ignore_index=True)135 except:136 # print("Hmm...")137 pass138 df_rel = df_rel.append(df_inv_rel, ignore_index = True)139 140 141with dropdowns:142 l_col, m_col, r_col = st.columns(3)143 if objects_u is not None:144 if 'Object ID' not in df_obj.columns:145 l_col.write('No object ID column found')146 else:147 start_obj = l_col.selectbox('Start object', 148 options = df_obj['Object ID'])149 else:150 start_obj = l_col.selectbox('Start object', 151 options = ['No objects found'])152 153 if relations_u is not None:154 conditions = m_col.multiselect('Conditions', 155 options = list(filter(lambda a: a != '-', df_rel['Condition'].unique())))156 else:157 conditions = m_col.multiselect('Conditions', 158 options = ['No conditions found'],159 default = ['No conditions found'])160 161 if relations_u is not None:162 163 164 rel_types = r_col.multiselect('Relation types', 165 166 options = df_rel['Relation type'].unique(),167 default = df_rel['Relation type'].unique()[0])168 inv_selected = []169 for t in rel_types:170 if t[0] == '(':171 inv_selected.append(t[10:])172 else:173 inv_selected.append('(inverse) {}'.format(t))174 175 for t in rel_types:176 if t in inv_selected:177 st.error("Error, can't select both the normal AND inverse relation of the same type.")178 break179 df_rel = df_rel.loc[~df_rel['Relation type'].isin(inv_selected)]180 else:181 rel_types = r_col.multiselect('Relation types', 182 options = ['No relations found'], 183 default = ['No relations found'])184 185 186 187 188with output_table:189 190 if objects_u is not None and relations_u is not None:191 if conditions is None:192 cds = ['-']193 else:194 cds = conditions.append('-')195 selection = []196 gl_config_error = ''197 198 df_obj = df_obj.set_index('Object ID')199 df_obj['highlight_type'] = '-'200 selector(start_obj, rel_types, conditions, df_rel, df_obj)201 df_obj = df_obj.reset_index()202 col_list = set_object_color(start_obj, selection, df_obj)203 df_obj['highlight_type'] = col_list204 205 206 st.subheader('Output table')207 208 209 210 if gl_config_error != '':211 st.write(gl_config_error)212 213 st.table()214 else:215 df_results = df_obj[df_obj['highlight_type'] != '-']216 df_results['highlight_type'] = pd.Categorical(df_results['highlight_type'], 217 ['start', 'intermediate', 'selected'])218 df_results = df_results.sort_values('highlight_type')219 df_results = df_results[['Object ID', 220 'Object type3', 221 'highlight_type']].reset_index(drop = True)222 df_results.index += 1223 st.table(df_results)224 225 226with dropdowns2:227 results = []228 l_col2, m_col2, r_col2 = st.columns(3)229 if objects_u is not None:230 if 'Object ID' not in df_obj.columns:231 l_col2.write('No object ID column found')232 else:233 start_obj2 = l_col2.selectbox('Assembly Object', 234 options = df_obj['Object ID'])235 else:236 start_obj2 = l_col2.selectbox('Assembly Object', 237 options = ['No objects found'])238 239 if relations_u is not None:240 241 242 rel_types2 = r_col2.multiselect('Assembly Relation(s)', 243 244 options = df_rel['Relation type'].unique(),245 default = df_rel['Relation type'].unique()[0])246 inv_selected2 = []247 for t in rel_types2:248 if t[0] == '(':249 inv_selected2.append(t[10:])250 else:251 inv_selected2.append('(inverse) {}'.format(t))252 253 for t in rel_types:254 if t in inv_selected2:255 st.error("Error, can't select both the normal AND inverse relation of the same type.")256 break257 df_rel = df_rel.loc[~df_rel['Relation type'].isin(inv_selected2)]258 else:259 rel_types = r_col.multiselect('Assembly Relation(s)', 260 options = ['No relations found'], 261 default = ['No relations found'])262with output_table2:263 264 if objects_u is not None and relations_u is not None:265 if conditions is None:266 cds = ['-']267 else:268 cds = conditions.append('-')269 selection = []270 gl_config_error = ''271 272 df_obj2 = df_obj.set_index('Object ID')273 df_obj2['highlight_type'] = '-'274 selector(start_obj2, rel_types2, conditions, df_rel, df_obj2)275 df_obj2 = df_obj2.reset_index()276 col_list = set_object_color(start_obj2, selection, df_obj2)277 df_obj2['highlight_type'] = col_list278 279 df_obj2 = pd.merge(df_obj2, df_obj, how='inner')280 st.subheader('Assembly Elements')281 282 if gl_config_error != '':283 st.write(gl_config_error)284 285 st.table()286 else:287 df_results = df_obj2[df_obj2['highlight_type'] != '-']288 df_results['highlight_type'] = pd.Categorical(df_results['highlight_type'], 289 ['start', 'intermediate', 'selected'])290 df_results = df_results.sort_values('highlight_type')291 df_results = df_results[['Object ID', 292 'Object type3', 293 'highlight_type']].reset_index(drop = True)294 df_results.index += 1...

Full Screen

Full Screen

destiny_activity_graph_node_featuring_state_definition.py

Source:destiny_activity_graph_node_featuring_state_definition.py Github

copy

Full Screen

...33 self.discriminator = None34 if highlight_type is not None:35 self.highlight_type = highlight_type36 @property37 def highlight_type(self):38 """Gets the highlight_type of this DestinyActivityGraphNodeFeaturingStateDefinition. # noqa: E50139 The node can be highlighted in a variety of ways - the game iterates through these and finds the first FeaturingState that is valid at the present moment given the Game, Account, and Character state, and renders the node in that state. See the ActivityGraphNodeHighlightType enum for possible values. # noqa: E50140 :return: The highlight_type of this DestinyActivityGraphNodeFeaturingStateDefinition. # noqa: E50141 :rtype: ActivityGraphNodeHighlightType42 """43 return self._highlight_type44 @highlight_type.setter45 def highlight_type(self, highlight_type):46 """Sets the highlight_type of this DestinyActivityGraphNodeFeaturingStateDefinition.47 The node can be highlighted in a variety of ways - the game iterates through these and finds the first FeaturingState that is valid at the present moment given the Game, Account, and Character state, and renders the node in that state. See the ActivityGraphNodeHighlightType enum for possible values. # noqa: E50148 :param highlight_type: The highlight_type of this DestinyActivityGraphNodeFeaturingStateDefinition. # noqa: E50149 :type: ActivityGraphNodeHighlightType50 """51 self._highlight_type = highlight_type52 def to_dict(self):53 """Returns the model properties as a dict"""54 result = {}55 for attr, _ in six.iteritems(self.openapi_types):56 value = getattr(self, attr)57 if isinstance(value, list):58 result[attr] = list(map(59 lambda x: x.to_dict() if hasattr(x, "to_dict") else x,...

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 SeleniumBase 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