简体   繁体   English

使用Selenium WebDriver或Java生成cpf

[英]Generate a cpf with Selenium WebDriver or Java

How do I generate a cpf , copy and paste into a register input with Selenium WebDriver or Java? 如何使用Selenium WebDriver或Java生成cpf ,复制并粘贴到寄存器输入中?

I need to generate the cpf along with the implementation of automated testing. 我需要生成the自动化测试的实施以及公积金。

Below is the logic used to generate CPF number for Brazil and it works fine for me. 以下是用于为巴西生成CPF编号的逻辑,对我来说效果很好。

int randNum2 = new Double( (Math.random()+1) * 100000000).intValue();
String aString`enter code here` = Integer.toString(randNum2);
int[] cpf = new int[aString.length()+3];
for (int i = 0; i < aString.length(); i++) {
    cpf[i] = Character.digit(aString.charAt(i), 10);
}
cpf[9]=10*cpf[0]+9*cpf[1]+8*cpf[2]+7*cpf[3]+6*cpf[4]+5*cpf[5]+4*cpf[6]+3*cpf[7]+2*cpf[8];
cpf[9]=11-(cpf[9] %11);
if(cpf[9]>9)
{
    cpf[9]=0;
}
cpf[10]=11*cpf[0]+10*cpf[1]+9*cpf[2]+8*cpf[3]+7*cpf[4]+6*cpf[5]+5*cpf[6]+4*cpf[7]+3*cpf[8]+2*cpf[9];
cpf[10]=11-(cpf[10] %11);
if(cpf[10]>9)
{
    cpf[10]=0;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM