(driver)
| 196 | |
| 197 | |
| 198 | def activate_jquery(driver): |
| 199 | # If "jQuery is not defined" on a website, use this method to activate it. |
| 200 | # This method is needed because jQuery is not always defined on web sites. |
| 201 | with suppress(Exception): |
| 202 | # Let's first find out if jQuery is already defined. |
| 203 | execute_script(driver, "jQuery('html');") |
| 204 | # Since that command worked, jQuery is defined. Let's return. |
| 205 | return |
| 206 | # jQuery is not defined. It will be loaded in the next part. |
| 207 | jquery_js = constants.JQuery.MIN_JS |
| 208 | add_js_link(driver, jquery_js) |
| 209 | for x in range(36): |
| 210 | # jQuery needs a small amount of time to activate. |
| 211 | try: |
| 212 | execute_script(driver, "jQuery('html');") |
| 213 | return |
| 214 | except TypeError as e: |
| 215 | if ( |
| 216 | ( |
| 217 | shared_utils.is_cdp_swap_needed(driver) |
| 218 | or hasattr(driver, "_swap_driver") |
| 219 | ) |
| 220 | and "cannot unpack non-iterable" in str(e) |
| 221 | ): |
| 222 | pass |
| 223 | else: |
| 224 | if x == 18: |
| 225 | add_js_link(driver, jquery_js) |
| 226 | time.sleep(0.1) |
| 227 | except Exception: |
| 228 | if x == 18: |
| 229 | add_js_link(driver, jquery_js) |
| 230 | time.sleep(0.1) |
| 231 | # Since jQuery still isn't activating, give up and raise an exception |
| 232 | raise_unable_to_load_jquery_exception(driver) |
| 233 | |
| 234 | |
| 235 | def are_quotes_escaped(string): |
no test coverage detected
searching dependent graphs…