Generate a cpf with Selenium WebDriver or Java -
how generate cpf, copy , paste register input selenium webdriver or java?
i need generate the cpf along implementation of automated testing.
below logic used generate cpf number brazil , works fine me.
int randnum2 = new double( (math.random()+1) * 100000000).intvalue(); string astring`enter code here` = integer.tostring(randnum2); int[] cpf = new int[astring.length()+3]; (int = 0; < 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; }
Comments
Post a Comment