How to use activate_jquery_confirm method in SeleniumBase

Best Python code snippet using SeleniumBase

jqc_helper.py

Source:jqc_helper.py Github

copy

Full Screen

...14 '</div>' +15 '</form>'"""16)17def jquery_confirm_button_dialog(driver, message, buttons, options=None):18 js_utils.activate_jquery_confirm(driver)19 # These defaults will be overwritten later if set20 theme = constants.JqueryConfirm.DEFAULT_THEME21 border_color = constants.JqueryConfirm.DEFAULT_COLOR22 width = constants.JqueryConfirm.DEFAULT_WIDTH23 if options:24 for option in options:25 if option[0].lower() == "theme":26 theme = option[1]27 elif option[0].lower() == "color":28 border_color = option[1]29 elif option[0].lower() == "width":30 width = option[1]31 else:32 raise Exception('Unknown option: "%s"' % option[0])33 if not message:34 message = ""35 key_row = ""36 if len(buttons) == 1: # There's only one button as an option37 key_row = "keys: ['enter', 'y', '1']," # Shortcut: "Enter","Y","1"38 b_html = (39 """button_%s: {40 btnClass: 'btn-%s',41 text: '<b>%s</b>',42 %s43 action: function(){44 jqc_status = '%s';45 $jqc_status = jqc_status;46 jconfirm.lastButtonText = jqc_status;47 }48 },"""49 )50 all_buttons = ""51 btn_count = 052 for button in buttons:53 btn_count += 154 text = button[0]55 text = js_utils.escape_quotes_if_needed(text)56 if len(buttons) > 1 and text.lower() == "yes":57 key_row = "keys: ['y'],"58 if btn_count < 10:59 key_row = "keys: ['y', '%s']," % btn_count60 elif len(buttons) > 1 and text.lower() == "no":61 key_row = "keys: ['n'],"62 if btn_count < 10:63 key_row = "keys: ['n', '%s']," % btn_count64 elif len(buttons) > 1:65 if btn_count < 10:66 key_row = "keys: ['%s']," % btn_count67 color = button[1]68 if not color:69 color = "blue"70 new_button = b_html % (btn_count, color, text, key_row, text)71 all_buttons += new_button72 content = (73 '<div></div><font color="#0066ee">%s</font>'74 "" % (message)75 )76 content = js_utils.escape_quotes_if_needed(content)77 overlay_opacity = "0.32"78 if theme.lower() == "supervan":79 overlay_opacity = "0.56"80 if theme.lower() == "bootstrap":81 overlay_opacity = "0.64"82 if theme.lower() == "modern":83 overlay_opacity = "0.5"84 if theme.lower() == "material":85 overlay_opacity = "0.4"86 jqcd = (87 """jconfirm({88 boxWidth: '%s',89 useBootstrap: false,90 containerFluid: true,91 bgOpacity: %s,92 type: '%s',93 theme: '%s',94 animationBounce: 1,95 typeAnimated: true,96 animation: 'scale',97 draggable: true,98 dragWindowGap: 1,99 container: 'body',100 title: '%s',101 content: '<div></div>',102 buttons: {103 %s104 }105 });"""106 % (107 width,108 overlay_opacity,109 border_color,110 theme,111 content,112 all_buttons113 )114 )115 driver.execute_script(jqcd)116def jquery_confirm_text_dialog(driver, message, button=None, options=None):117 js_utils.activate_jquery_confirm(driver)118 # These defaults will be overwritten later if set119 theme = constants.JqueryConfirm.DEFAULT_THEME120 border_color = constants.JqueryConfirm.DEFAULT_COLOR121 width = constants.JqueryConfirm.DEFAULT_WIDTH122 if not message:123 message = ""124 if button:125 if not type(button) is list and not type(button) is tuple:126 raise Exception('"button" should be a (text, color) tuple!')127 if len(button) != 2:128 raise Exception('"button" should be a (text, color) tuple!')129 else:130 button = ("Submit", "blue")131 if options:132 for option in options:133 if option[0].lower() == "theme":134 theme = option[1]135 elif option[0].lower() == "color":136 border_color = option[1]137 elif option[0].lower() == "width":138 width = option[1]139 else:140 raise Exception('Unknown option: "%s"' % option[0])141 btn_text = button[0]142 btn_color = button[1]143 if not btn_color:144 btn_color = "blue"145 content = (146 '<div></div><font color="#0066ee">%s</font>'147 "" % (message)148 )149 content = js_utils.escape_quotes_if_needed(content)150 overlay_opacity = "0.32"151 if theme.lower() == "supervan":152 overlay_opacity = "0.56"153 if theme.lower() == "bootstrap":154 overlay_opacity = "0.64"155 if theme.lower() == "modern":156 overlay_opacity = "0.5"157 if theme.lower() == "material":158 overlay_opacity = "0.4"159 jqcd = (160 """jconfirm({161 boxWidth: '%s',162 useBootstrap: false,163 containerFluid: true,164 bgOpacity: %s,165 type: '%s',166 theme: '%s',167 animationBounce: 1,168 typeAnimated: true,169 animation: 'scale',170 draggable: true,171 dragWindowGap: 1,172 container: 'body',173 title: '%s',174 content: '<div></div>' +175 %s,176 buttons: {177 formSubmit: {178 btnClass: 'btn-%s',179 text: '%s',180 action: function () {181 jqc_input = this.$content.find('.jqc_input').val();182 $jqc_input = this.$content.find('.jqc_input').val();183 jconfirm.lastInputText = jqc_input;184 $jqc_status = '%s'; // There is only one button185 },186 },187 },188 onContentReady: function () {189 var jc = this;190 this.$content.find('form.jqc_form').on('submit', function (e) {191 // User submits the form by pressing "Enter" in the field192 e.preventDefault();193 jc.$$formSubmit.trigger('click'); // Click the button194 });195 }196 });"""197 % (198 width,199 overlay_opacity,200 border_color,201 theme,202 content,203 form_code,204 btn_color,205 btn_text,206 btn_text207 )208 )209 driver.execute_script(jqcd)210def jquery_confirm_full_dialog(driver, message, buttons, options=None):211 js_utils.activate_jquery_confirm(driver)212 # These defaults will be overwritten later if set213 theme = constants.JqueryConfirm.DEFAULT_THEME214 border_color = constants.JqueryConfirm.DEFAULT_COLOR215 width = constants.JqueryConfirm.DEFAULT_WIDTH216 if not message:217 message = ""218 btn_count = 0219 b_html = (220 """button_%s: {221 btnClass: 'btn-%s',222 text: '%s',223 action: function(){224 jqc_input = this.$content.find('.jqc_input').val();225 $jqc_input = this.$content.find('.jqc_input').val();...

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