16
16
17
17
import os
18
18
19
+ from robot .libraries .BuiltIn import BuiltIn
20
+
19
21
from SeleniumLibrary .base import LibraryComponent , keyword
20
22
from SeleniumLibrary .errors import ElementNotFound
21
23
from SeleniumLibrary .utils import is_noney , is_truthy
@@ -231,16 +233,15 @@ def input_password(self, locator, password, clear=True):
231
233
232
234
| Input Password | password_field | ${PASSWORD} |
233
235
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.
239
239
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.
241
242
"""
242
243
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 )
244
245
245
246
@keyword
246
247
def input_text (self , locator , text , clear = True ):
@@ -266,7 +267,7 @@ def input_text(self, locator, text, clear=True):
266
267
argument are new in SeleniumLibrary 4.0
267
268
"""
268
269
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 )
270
271
271
272
@keyword
272
273
def page_should_contain_textfield (self , locator , message = None , loglevel = 'TRACE' ):
@@ -421,8 +422,15 @@ def _get_value_from_radio_buttons(self, elements):
421
422
return element .get_attribute ('value' )
422
423
return None
423
424
424
- def _input_text_into_text_field (self , locator , text , clear ):
425
+ def _input_text_into_text_field (self , locator , text , clear , disable_log ):
425
426
element = self .find_element (locator )
426
427
if is_truthy (clear ):
427
428
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