1616
1717import os
1818
19+ from robot .libraries .BuiltIn import BuiltIn
20+
1921from SeleniumLibrary .base import LibraryComponent , keyword
2022from SeleniumLibrary .errors import ElementNotFound
2123from SeleniumLibrary .utils import is_noney , is_truthy
@@ -231,16 +233,15 @@ def input_password(self, locator, password, clear=True):
231233
232234 | Input Password | password_field | ${PASSWORD} |
233235
234- Notice also that SeleniumLibrary logs all the communication with
235- browser drivers using the DEBUG level, and the actual password can
236- be seen there. Additionally, Robot Framework logs all arguments using
237- the TRACE level. Tests must thus not be executed using level below
238- INFO if the password should not be logged in any format.
236+ Please notice that Robot Framework logs all arguments using
237+ the TRACE level and tests must not be executed using level below
238+ DEBUG if the password should not be logged in any format.
239239
240- The `clear` argument is new in SeleniumLibrary 4.0
240+ The `clear` argument is new in SeleniumLibrary 4.0. Hiding password
241+ logging from Selenium logs is new in SeleniumLibrary 4.2.
241242 """
242243 self .info ("Typing password into text field '%s'." % locator )
243- self ._input_text_into_text_field (locator , password , clear )
244+ self ._input_text_into_text_field (locator , password , clear , True )
244245
245246 @keyword
246247 def input_text (self , locator , text , clear = True ):
@@ -266,7 +267,7 @@ def input_text(self, locator, text, clear=True):
266267 argument are new in SeleniumLibrary 4.0
267268 """
268269 self .info ("Typing text '%s' into text field '%s'." % (text , locator ))
269- self ._input_text_into_text_field (locator , text , clear )
270+ self ._input_text_into_text_field (locator , text , clear , False )
270271
271272 @keyword
272273 def page_should_contain_textfield (self , locator , message = None , loglevel = 'TRACE' ):
@@ -421,8 +422,15 @@ def _get_value_from_radio_buttons(self, elements):
421422 return element .get_attribute ('value' )
422423 return None
423424
424- def _input_text_into_text_field (self , locator , text , clear ):
425+ def _input_text_into_text_field (self , locator , text , clear , disable_log ):
425426 element = self .find_element (locator )
426427 if is_truthy (clear ):
427428 element .clear ()
428- element .send_keys (text )
429+ if disable_log :
430+ self .info ('Temporally setting log level to: NONE' )
431+ previous_level = BuiltIn ().set_log_level ('NONE' )
432+ try :
433+ element .send_keys (text )
434+ finally :
435+ if disable_log :
436+ BuiltIn ().set_log_level (previous_level )
0 commit comments