Enters into the field a Multi-Factor Authentication TOTP Code. If the "totp_key" is not specified, this method defaults to using the one provided in [seleniumbase/config/settings.py]. The TOTP code is generated by the Google Authenticator Algorithm. This method will a
(
self, selector, totp_key=None, by="css selector", timeout=None
)
| 9030 | return shared_utils.get_mfa_code(totp_key) |
| 9031 | |
| 9032 | def enter_mfa_code( |
| 9033 | self, selector, totp_key=None, by="css selector", timeout=None |
| 9034 | ): |
| 9035 | """Enters into the field a Multi-Factor Authentication TOTP Code. |
| 9036 | If the "totp_key" is not specified, this method defaults |
| 9037 | to using the one provided in [seleniumbase/config/settings.py]. |
| 9038 | The TOTP code is generated by the Google Authenticator Algorithm. |
| 9039 | This method will automatically press ENTER after typing the code.""" |
| 9040 | self.__check_scope() |
| 9041 | if not timeout: |
| 9042 | timeout = settings.SMALL_TIMEOUT |
| 9043 | if self.__is_cdp_swap_needed(): |
| 9044 | mfa_code = self.get_mfa_code(totp_key) |
| 9045 | self.cdp.type(selector, mfa_code + "\n", timeout=timeout) |
| 9046 | return |
| 9047 | self.wait_for_element_visible(selector, by=by, timeout=timeout) |
| 9048 | if self.recorder_mode and self.__current_url_is_recordable(): |
| 9049 | if self.get_session_storage_item("pause_recorder") == "no": |
| 9050 | css_selector = self.convert_to_css_selector(selector, by=by) |
| 9051 | time_stamp = self.execute_script("return Date.now();") |
| 9052 | sel_key = [css_selector, totp_key] |
| 9053 | origin = self.get_origin() |
| 9054 | action = ["e_mfa", sel_key, origin, time_stamp] |
| 9055 | self.__extra_actions.append(action) |
| 9056 | # Sometimes Sign-In leaves the origin... Save work first. |
| 9057 | self.save_recorded_actions() |
| 9058 | mfa_code = self.get_mfa_code(totp_key) |
| 9059 | self.update_text(selector, mfa_code + "\n", by=by, timeout=timeout) |
| 9060 | |
| 9061 | def convert_css_to_xpath(self, css): |
| 9062 | return css_to_xpath.convert_css_to_xpath(css) |
no test coverage detected