How to use add_css_link method in SeleniumBase

Best Python code snippet using SeleniumBase

tour_helper.py

Source:tour_helper.py Github

copy

Full Screen

...26 js_utils.wait_for_ready_state_complete(driver)27 js_utils.wait_for_angularjs(driver)28 for x in range(4):29 js_utils.activate_jquery(driver)30 js_utils.add_css_link(driver, bootstrap_tour_css)31 js_utils.add_js_link(driver, bootstrap_tour_js)32 time.sleep(0.1)33 for x in range(int(settings.MINI_TIMEOUT * 2.0)):34 # Bootstrap needs a small amount of time to load & activate.35 try:36 driver.execute_script(verify_script)37 time.sleep(0.05)38 return39 except Exception:40 time.sleep(0.15)41 js_utils.raise_unable_to_load_jquery_exception(driver)42def is_bootstrap_activated(driver):43 verify_script = ("""// Verify Bootstrap Tour activated44 var tour2 = new Tour({45 });""")46 try:47 driver.execute_script(verify_script)48 return True49 except Exception:50 return False51def activate_hopscotch(driver):52 """ Allows you to use Hopscotch Tours with SeleniumBase53 http://linkedin.github.io/hopscotch/54 """55 hopscotch_css = constants.Hopscotch.MIN_CSS56 hopscotch_js = constants.Hopscotch.MIN_JS57 backdrop_style = style_sheet.hops_backdrop_style58 verify_script = ("""// Verify Hopscotch activated59 var hops = hopscotch.isActive;60 """)61 activate_bootstrap(driver)62 js_utils.wait_for_ready_state_complete(driver)63 js_utils.wait_for_angularjs(driver)64 js_utils.add_css_style(driver, backdrop_style)65 for x in range(4):66 js_utils.activate_jquery(driver)67 js_utils.add_css_link(driver, hopscotch_css)68 js_utils.add_js_link(driver, hopscotch_js)69 time.sleep(0.1)70 for x in range(int(settings.MINI_TIMEOUT * 2.0)):71 # Hopscotch needs a small amount of time to load & activate.72 try:73 driver.execute_script(verify_script)74 js_utils.wait_for_ready_state_complete(driver)75 js_utils.wait_for_angularjs(driver)76 time.sleep(0.05)77 return78 except Exception:79 time.sleep(0.15)80 js_utils.raise_unable_to_load_jquery_exception(driver)81def is_hopscotch_activated(driver):82 verify_script = ("""// Verify Hopscotch activated83 var hops = hopscotch.isActive;84 """)85 try:86 driver.execute_script(verify_script)87 return True88 except Exception:89 return False90def activate_introjs(driver):91 """ Allows you to use IntroJS Tours with SeleniumBase92 https://introjs.com/93 """94 intro_css = constants.IntroJS.MIN_CSS95 intro_js = constants.IntroJS.MIN_JS96 verify_script = ("""// Verify IntroJS activated97 var intro2 = introJs();98 """)99 activate_bootstrap(driver)100 js_utils.wait_for_ready_state_complete(driver)101 js_utils.wait_for_angularjs(driver)102 for x in range(4):103 js_utils.activate_jquery(driver)104 js_utils.add_css_link(driver, intro_css)105 js_utils.add_js_link(driver, intro_js)106 time.sleep(0.1)107 for x in range(int(settings.MINI_TIMEOUT * 2.0)):108 # IntroJS needs a small amount of time to load & activate.109 try:110 driver.execute_script(verify_script)111 js_utils.wait_for_ready_state_complete(driver)112 js_utils.wait_for_angularjs(driver)113 time.sleep(0.05)114 return115 except Exception:116 time.sleep(0.15)117 js_utils.raise_unable_to_load_jquery_exception(driver)118def is_introjs_activated(driver):119 verify_script = ("""// Verify IntroJS activated120 var intro2 = introJs();121 """)122 try:123 driver.execute_script(verify_script)124 return True125 except Exception:126 return False127def activate_shepherd(driver):128 """ Allows you to use Shepherd Tours with SeleniumBase129 http://github.hubspot.com/shepherd/docs/welcome/130 """131 shepherd_js = constants.Shepherd.MIN_JS132 sh_theme_arrows_css = constants.Shepherd.THEME_ARROWS_CSS133 sh_theme_arrows_fix_css = constants.Shepherd.THEME_ARR_FIX_CSS134 sh_theme_default_css = constants.Shepherd.THEME_DEFAULT_CSS135 sh_theme_dark_css = constants.Shepherd.THEME_DARK_CSS136 sh_theme_sq_css = constants.Shepherd.THEME_SQ_CSS137 sh_theme_sq_dark_css = constants.Shepherd.THEME_SQ_DK_CSS138 tether_js = constants.Tether.MIN_JS139 spinner_css = constants.Messenger.SPINNER_CSS140 sh_style = style_sheet.sh_style_test141 backdrop_style = style_sheet.sh_backdrop_style142 activate_bootstrap(driver)143 js_utils.wait_for_ready_state_complete(driver)144 js_utils.wait_for_angularjs(driver)145 js_utils.add_css_style(driver, backdrop_style)146 js_utils.wait_for_ready_state_complete(driver)147 js_utils.wait_for_angularjs(driver)148 for x in range(4):149 js_utils.add_css_link(driver, spinner_css)150 js_utils.add_css_link(driver, sh_theme_arrows_css)151 js_utils.add_css_link(driver, sh_theme_arrows_fix_css)152 js_utils.add_css_link(driver, sh_theme_default_css)153 js_utils.add_css_link(driver, sh_theme_dark_css)154 js_utils.add_css_link(driver, sh_theme_sq_css)155 js_utils.add_css_link(driver, sh_theme_sq_dark_css)156 js_utils.add_js_link(driver, tether_js)157 js_utils.add_js_link(driver, shepherd_js)158 time.sleep(0.1)159 for x in range(int(settings.MINI_TIMEOUT * 2.0)):160 # Shepherd needs a small amount of time to load & activate.161 try:162 driver.execute_script(sh_style) # Verify Shepherd has loaded163 js_utils.wait_for_ready_state_complete(driver)164 js_utils.wait_for_angularjs(driver)165 driver.execute_script(sh_style) # Need it twice for ordering166 js_utils.wait_for_ready_state_complete(driver)167 js_utils.wait_for_angularjs(driver)168 time.sleep(0.05)169 return...

Full Screen

Full Screen

webpage.py

Source:webpage.py Github

copy

Full Screen

...12 self.script_list=script_list13 # CSS14 def add_css(include_type, include_data):15 self.css_list.append(dict("type"=include_type, "data"=include_data))16 def add_css_link(css_url):17 self.add_css("link", css_url)18 def add_css_inline(css_data):19 self.add_css_link("inline", css_data)20 # Scripts21 def add_script(include_type, include_data, language, charset=DEFAULT_CHARSET):22 self.script_list.append(dict("type"=include_type, "data"=include_data, "language"=language, "charset"=charset))23 def add_script_link(script_url, language, charset=DEFAULT_CHARSET):24 self.add_script("link", script_url, language, charset)25 def add_script_inline(script_data, language, charset=DEFAULT_CHARSET):26 self.add_script("inline", script_data, language, charset)27 # JS Scripts28 def add_js_link(script_url, charset=DEFAULT_CHARSET):...

Full Screen

Full Screen

helper.py

Source:helper.py Github

copy

Full Screen

...14 return self.request.registry['js_codes']15 def add_js_link(self, link, index=None):16 self.request.add_js_link(link, index)17 return ''18 def add_css_link(self, link):19 self.request.add_css_link(link)20 return ''21 def generate_js_links(self):22 return self.render_for('js_links.jinja2', {'links': self.js_links})23 def generate_css_links(self):24 return self.render_for('css_links.jinja2', {'links': self.css_links})25 def generate_js_codes(self):...

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