Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide login credentials in log.html file in robotframework

I have tried using --removekeywords name:Login(keyword) in the command line but the log.html file doesn't hide the keyword.

Can anyone please help me out at least to flatten the Login keyword in log.html file

like image 424
Uday Avatar asked Mar 12 '18 14:03

Uday


2 Answers

If you want to hide credentials, there are two things you should do. First, make sure the credentials are stored in variables rather than hard-coded in the call to the Login keyword.

Second, use --removekeywords to remove the Login keyword from the log and report files. Note that the name you give to --removekeywords must match the full name of the keyword.

For example, let's imagine you have a resource file named Keywords.robot that defines your Login keyword:

# Keywords.robot
*** Keywords ***
Login
    [Arguments]  ${username}  ${password}
    log  your super secret password is ${password}

Now, consider a test case that uses this keyword:

# example.robot
*** Settings ***
Resource  Keywords.robot

*** Variables ***
${Username}  [email protected]
${Password}  SuperSecret!

*** Test cases ***
Example
    do something
    login  ${username}  ${password}
    do something else

If you do not use --removekeywords, the log will show this:

enter image description here

If you use --removekeywords NAME:Keywords.Login then you will see this:

enter image description here

like image 94
Bryan Oakley Avatar answered Oct 17 '22 13:10

Bryan Oakley


You can use custom keyword for all sensitive inputs which will work just as "Input Text" (selenium library) accepting the same arguments but not logging into output.xml

Sensitive Input
   Set Log Level    NONE
   [Arguments]  ${locator}  ${value}
   Input Text  ${locator}  ${value}
   Set Log Level    INFO
like image 21
Dron Avatar answered Oct 17 '22 14:10

Dron