How to remove maskara from CPF to library FakerLibrary?

I’m using the library FakerLibrary in the portuguese version.

When generating CPF it brings CPF with mask example: 109.694.257-94 but I wanted to remove the mask in the CPF generated. Example of how to generate 10969425794. How do I remove the mask?

Result:

Code:

i*** Settings ***

Documentation Documentação da API: xxxxxxxxx
Library RequestsLibrary
Library Collections
Library FakerLibrary locale=pt_BR
Library String

*** Variable ***
${URL_API} local/api/profile/user

*** Keywords ***
####SETUP E TEARDOWNS
Conectar a minha API
Create Session fakeAPI ${URL_API}
${HEADERS} Create Dictionary content-type=application/json
Set Suite Variable ${HEADERS}

Cadastrar um novo cliente

${NOME}        FakerLibrary.name
${CPF}         FakerLibrary.CPF
${EMAILFAKE}   FakerLibrary.Email
${TELEFONE}    Generate Random String    length=11    chars=[NUMBERS]     
${RESPOSTA}    Post Request   fakeAPI    create
...                           data={"email": "${EMAILFAKE}","gender":"M","cpf":"${CPF}","name": "${NOME}", "password": "Code147@","role":"CLIENT", "telephone": "${TELEFONE}"}
...                           headers=${HEADERS}
Log            ${RESPOSTA.text}
Set Test Variable    ${RESPOSTA}

Hi Nicolle,

Well there may be a way to configure Faker library to do what you want but I don’t know it unless it involved creating a custom region that is a variation of your pt but that seems like a lot of effort?

Sometime a simple solution gets you there quicker like Replace String

You already have a CPF number (i’m guessing there might be some kind of rules around this number and it’s not just a random 11 digit number? so I suggest changing this line:

${CPF}         FakerLibrary.CPF

to:

${CPF_FORMATTED}         FakerLibrary.CPF

Then in your test case you can simply:

${CPF_PLAIN}=   	Replace String   	${CPF_FORMATTED}   	.   	${EMPTY}
${CPF_PLAIN}=   	Replace String   	${CPF_PLAIN}   	-   	${EMPTY}

The reason I suggest this way is i’m guessing that you want the plain number for entering into a form where the input field will automagically handle the formatting so here you use ${CPF_PLAIN}, if so quite likely later in your process you will need to validate this CPF number on a later screen is the number you entered and it will be displayed with formatting, so here you can use ${CPF_FORMATTED} for validating the number entered.

Hope this helped,

Dave.