@@ -1393,6 +1393,17 @@ def get_element_html(self, selector):
13931393 )
13941394 )
13951395
1396+ def get_mfa_code (self , totp_key = None ):
1397+ """Returns a time-based one-time password based on the Google
1398+ Authenticator algorithm for multi-factor authentication."""
1399+ return shared_utils .get_mfa_code (totp_key )
1400+
1401+ def enter_mfa_code (self , selector , totp_key = None , timeout = None ):
1402+ if not timeout :
1403+ timeout = settings .SMALL_TIMEOUT
1404+ mfa_code = self .get_mfa_code (totp_key )
1405+ self .type (selector , mfa_code + "\n " , timeout = timeout )
1406+
13961407 def set_locale (self , locale ):
13971408 """(Settings will take effect on the next page load)"""
13981409 self .loop .run_until_complete (self .page .set_locale (locale ))
@@ -1430,6 +1441,26 @@ def set_attributes(self, selector, attribute, value):
14301441 with suppress (Exception ):
14311442 self .loop .run_until_complete (self .page .evaluate (js_code ))
14321443
1444+ def is_attribute_present (self , selector , attribute , value = None ):
1445+ try :
1446+ element = self .find_element (selector , timeout = 0.1 )
1447+ found_value = element .get_attribute (attribute )
1448+ if found_value is None :
1449+ return False
1450+ if value is not None :
1451+ if found_value == value :
1452+ return True
1453+ else :
1454+ return False
1455+ else :
1456+ return True
1457+ except Exception :
1458+ return False
1459+
1460+ def is_online (self ):
1461+ js_code = "navigator.onLine;"
1462+ return self .loop .run_until_complete (self .page .evaluate (js_code ))
1463+
14331464 def __make_sure_pyautogui_lock_is_writable (self ):
14341465 with suppress (Exception ):
14351466 shared_utils .make_writable (constants .MultiBrowser .PYAUTOGUILOCK )
0 commit comments