How to use choose_radio method in lettuce_webdriver

Best Python code snippet using lettuce_webdriver_python

first_try.py

Source:first_try.py Github

copy

Full Screen

1import streamlit as st2from map_layer import draw_map3from preparation.data_praparation import aggregate_data4from settings.settings import LOCAL_DATA_PATH5from visualisations.visual import draw_piechart, draw_error_plot, draw_all_station_chart6import numpy as np7import pandas as pd8from preparation import data_praparation as dprep, data_praparation9from forecasting_metrics import evaluate_all10import ssl11# -- Set page config12app_title = 'Stations map'13st.set_page_config(page_title=app_title, page_icon=":eyeglasses:", layout="wide")14# -- Default detector list15page_list = ['map', 'station', 'V1']16# -- Choose page17page = st.sidebar.selectbox('Page', page_list)18# uploaded_file = st.sidebar.file_uploader("Choose a file", type="xlsx")19ssl._create_default_https_context = ssl._create_unverified_context20uploaded_file = 'https://raw.githubusercontent.com/Vladykart/clean_dashboard/master/data/mart_operative_forecasting_results.csv'21if uploaded_file is not None:22 data = dprep.load_and_prepare_data(uploaded_file)23 aggregated_data = aggregate_data(data.copy())24 data_load_state = st.sidebar.text('Loading data...')25 data_load_state.text("Done! (using st.cache)")26 st.sidebar.success('File was successfully uploaded')27else:28 st.warning('First you need to upload excel file')29 data = []30 aggregated_data = []31d = st.sidebar.date_input(32 "Select date",33 value=data['date'].max().date(),34 min_value=data['date'].min().date(),35 max_value=data['date'].max().date())36st.write('Selected date id: :', d)37if page == 'map':38 col_1, col_2 = st.columns([19, 8])39 v_data = aggregated_data.loc[:, [d.strftime('%Y-%m-%d')], :]40 st.title('Stations map')41 choose_list = ('yeild', 'forecast', 'error',)42 choose_radio = st.sidebar.radio('Choose metric', choose_list)43 map_data = data.groupby(44 by=['date', 'site', 'region']).agg(45 {'yeild': 'sum',46 'forecast': 'sum',47 'error': 'mean',48 'lat': 'first',49 'lon': 'first'}).reset_index()50 map_data = map_data[map_data['date'] == d.strftime('%Y-%m-%d')]51 map_data['error'] = map_data['error'].abs()52 midpoint = (np.average(map_data["lat"]), np.average(map_data["lon"]))53 # match choose_radio:54 # case 'forecast':55 # forecast_map_data = map_data[['site', 'forecast', 'lat', 'lon']]56 # draw_map(forecast_map_data, midpoint[0], midpoint[1], 5)57 # case 'error':58 # error_map_data = map_data[['site', 'error', 'lat', 'lon']]59 # draw_map(error_map_data, midpoint[0], midpoint[1], 5)60 # case _:61 # yeild_map_data = map_data[['site', 'yeild', 'lat', 'lon']]62 # draw_map(yeild_map_data, midpoint[0], midpoint[1], 5)63 if choose_radio == 'forecast':64 forecast_map_data = map_data[['site', 'forecast', 'lat', 'lon']]65 with col_1:66 draw_map(forecast_map_data, midpoint[0], midpoint[1], 5)67 elif choose_radio == 'error':68 error_map_data = map_data[['site', 'error', 'lat', 'lon']]69 with col_1:70 draw_map(error_map_data, midpoint[0], midpoint[1], 5)71 else:72 yeild_map_data = map_data[['site', 'yeild', 'lat', 'lon']]73 with col_1:74 draw_map(yeild_map_data, midpoint[0], midpoint[1], 5)75 map_data = map_data.sort_values('yeild').set_index('site')76 with col_2:77 c = st.container()78 c.plotly_chart(draw_piechart(v_data).update_layout(width=550))79 col_3, col_4, col_5 = st.columns([16, 8, 8])80 with col_3:81 c1 = st.container()82 c1.plotly_chart(83 draw_all_station_chart(v_data, sort_by=choose_radio).update_layout(84 template='plotly_dark',85 paper_bgcolor='rgba(0,0,0,0)',86 plot_bgcolor='rgba(0,0,0,0)'87 ))88 with col_5:89 c2 = st.container()90 c2.plotly_chart(draw_error_plot(data.groupby(by=['hour']).agg('sum')).update_layout(91 template='plotly_dark',92 paper_bgcolor='rgba(0,0,0,0)',93 plot_bgcolor='rgba(0,0,0,0)'94 ))95 st.table(map_data)96elif page == 'station':97 st.title('Stations charts')98 # Title the app99 st.markdown("""100 * Use the menu at left to select data and set plot parameters101 * Your plots will appear below102 """)103 site = st.sidebar.multiselect(104 'Select station', data.site.unique(), help='choose station or stations', default=data.site.unique()[0])105 if site:106 for s in site:107 with st.expander(label=s):108 t_data = data[data['site'] == s]109 t_data = t_data.set_index('hour')110 t_data = t_data[t_data['date'] == d.strftime('%Y-%m-%d')]111 predicted = t_data['forecast'].abs()112 actual = t_data['yeild'].abs()113 t_aggregated_data = aggregated_data.loc[s, [d.strftime('%Y-%m-%d')], :]114 col_1, col_2 = st.columns([43, 100])115 with col_1:116 st.table(t_data[['forecast', 'yeild', 'error']])117 with col_2:118 c = st.container()119 c.bar_chart(t_data[['forecast', 'yeild', 'error']], width=1080, height=400)120 c.plotly_chart(draw_piechart(t_aggregated_data).update_layout(width=550))121 st.plotly_chart(draw_error_plot(t_data).update_layout(width=1000,122 height=600,123 template='plotly_dark',124 paper_bgcolor='rgba(0,0,0,0)',125 plot_bgcolor='rgba(0,0,0,0)'126 ))127 col_3, col_4 = st.columns([43, 100])128 with col_3:129 e = evaluate_all(actual, predicted)130 e = pd.DataFrame([e])131 err = st.multiselect(132 f'Error metrics for {s}: ', e.T.index.tolist(), help='choose error metrics',133 default=['mae', 'rmse', 'mse'])134 with col_4:135 st.table(e[err].T)136 # c.bar_chart(t_data[['error_shortage', 'error_excess']].abs(), width=1080, height=400)137elif page == 'V1':138 v_data = aggregated_data.loc[:, [d.strftime('%Y-%m-%d')], :]139 metrics_df = v_data.describe()140 choose_list = ('yeild', 'forecast', 'error_shortage', 'error_excess')141 col_1, col_2 = st.columns([1, 6])142 with col_1:143 choose_radio = st.radio('Choose sort metric', choose_list)144 with col_2:145 st.table(metrics_df)146 st.plotly_chart(147 draw_all_station_chart(v_data, sort_by=choose_radio).update_layout(width=1200,148 height=600,149 template='plotly_dark',150 paper_bgcolor='rgba(0,0,0,0)',151 plot_bgcolor='rgba(0,0,0,0)'...

Full Screen

Full Screen

households.py

Source:households.py Github

copy

Full Screen

...35 self.browser.fill_form(self.values)36 def validate_household_created(self):37 assert self.browser.is_text_present("Household successfully registered.")38 def has_children(self, value):39 self.choose_radio('has_children', value)40 def are_children_fields_disabled(self, is_disabled=True):41 for element_id in ['aged_between_5_12_years', 'aged_between_13_17_years']:42 element_id = 'household-children-' + element_id43 assert self.is_disabled(element_id) == is_disabled44 self.are_children_below_5_fields_disabled(is_disabled=is_disabled)45 def is_no_below_5_checked(self):46 assert self.browser.find_by_id('household-children-has_children_below_5_1').selected == True47 def cannot_say_yes_to_below_5(self):48 assert self.is_disabled("household-children-has_children_below_5_0") == True49 self.are_children_fields_disabled()50 def has_children_below_5(self, value):51 self.choose_radio('has_children_below_5', value)52 def are_children_below_5_fields_disabled(self, is_disabled=True):53 for element_id in ['aged_between_0_5_months', 'aged_between_6_11_months', 'aged_between_12_23_months',54 'aged_between_24_59_months']:55 element_id = 'household-children-' + element_id56 assert self.is_disabled(element_id) == is_disabled57 def has_women(self, value):58 self.choose_radio('has_women', value)59 def are_women_fields_disabled(self, is_disabled=True):60 for element_id in ['aged_between_15_19_years', 'aged_between_20_49_years']:61 element_id = 'household-women-' + element_id62 assert self.is_disabled(element_id) == is_disabled63 def fill_in_number_of_females_lower_than_sum_of_15_19_and_20_49(self):64 self.browser.fill('number_of_females', '1')65 self.browser.fill('aged_between_15_19_years', '2')66 self.browser.fill('aged_between_20_49_years', '3')67 def see_an_error_on_number_of_females(self):68 self.is_text_present(69 'Please enter a value that is greater or equal to the total number of women above 15 years age.')70 def choose_occupation(self, occupation_value):71 self.browser.select('occupation', occupation_value)72 def is_specify_visible(self, status=True):...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

1from time import sleep2from selenium import webdriver3from selenium.webdriver.common.keys import Keys4from selenium.webdriver.common.by import By5# has the "next" button clicked6def click_next_button(driver):7 button_next = driver.find_element(By.CSS_SELECTOR, "input#NextButton")8 button_next.click()9# has the best option selected, regardless of the questions amount10def choose_best_option(driver):11 choose_radio = driver.find_elements(By.CSS_SELECTOR, 'td[class^="Opt5"')12 for radio in choose_radio:13 radio.click()14# selects yes or no option for that question type15def choose_yes_no(driver, answer: str):16 if answer.lower() == "no":17 choose_radio = driver.find_elements(By.CSS_SELECTOR, 'td[class^="Opt2"')18 else:19 choose_radio = driver.find_elements(By.CSS_SELECTOR, 'td[class^="Opt1"')20 for radio in choose_radio:21 radio.click()22# selects the last option for the dropdowns question23def choose_dropdowns(driver):24 dropdowns = driver.find_elements(By.TAG_NAME, "select")25 for options in dropdowns:26 click_option = options.find_element(By.CLASS_NAME, "Opt9")27 click_option.click()28# selects text box area and types review29def type_review(driver):30 choose_area = driver.find_element(By.TAG_NAME, "textarea")31 choose_area.send_keys("Great food." + Keys.RETURN + "Great prices." + Keys.RETURN + "Great service.")32def main():33 # ask for survey code and validate format34 survey_code = input("\nType in your survey code, including dashes: ")35 if survey_code.count("-") != 5:36 raise Exception("\nPlease include all dashes!")37 survey_code = survey_code.split("-")38 39 # init FireFox driver and navigate to website40 driver = webdriver.Firefox()41 driver.get("https://www.pandaguestexperience.com")42 sleep(1)43 # return list of input elements for the code44 code_input = driver.find_elements(By.CSS_SELECTOR, "p.IndexText01 input")45 # input survey code into input elements46 i = 047 for block in code_input:48 block.send_keys(survey_code[i])49 i += 150 51 # find and click the 'submit' button52 button_submit = driver.find_element(By.CSS_SELECTOR, "div#Buttonholder input")53 button_submit.click()54 # Format of pages in order: 55 # 4 pages of multiple radio questions, 1 page of yes/no radio questions, 1 page of multiple radio questions56 # 1 page of text review questions, 1 page of multiple radio questions, 1 page of yes/no questions57 # 1 page of multiple radio questions (diff format), 1 page of yes/no questions, 1 page of multiple radio questions58 # 1 page of dropdown questions59 # First 4 pages60 for i in range(4):61 choose_best_option(driver)62 click_next_button(driver)63 # Pg 564 choose_yes_no(driver, "no")65 click_next_button(driver)66 # Pg 667 choose_best_option(driver)68 click_next_button(driver)69 70 # Pg 771 type_review(driver)72 click_next_button(driver)73 # Pg 874 choose_best_option(driver)75 click_next_button(driver)76 # Pg 977 choose_yes_no(driver, "no")78 click_next_button(driver)79 # Pg 1080 choose_radio = driver.find_element(By.CLASS_NAME, 'radioSimpleInput')81 choose_radio.click()82 click_next_button(driver)83 # Pg 1184 choose_yes_no(driver, "no")85 click_next_button(driver)86 # Pg 1287 choose_best_option(driver)88 click_next_button(driver)89 # Pg 1390 choose_dropdowns(driver)91 click_next_button(driver)92 # waits 30 seconds for user to jot down code93 # and then quits the driver session94 sleep(30)95 print("Closing session...")96 driver.quit()97# start if not imported98if __name__ == "__main__":...

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