Boa tarde,
Estou trabalhando com selenium utilizando o Java, mas estou com dificuldade de navegar pelo site que que o acesso é via certificado digital. Já tentei diversas formas e não tive êxito. Alguém poderia me ajudar?
Segue meu código abaixo:
package selenium1;
import java.io.File;
import static java.lang.Thread.sleep;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
/**
*
-
@author Lucas
*/
public class Selenium1 extends SeleniumSslProxy {/**
-
@param args the command line arguments */ private static WebDriver driver = null; private static SeleniumSslProxy proxy; public static void main(String[] args) throws InterruptedException { // TODO code application logic here <a href="//System.setProperty">//System.setProperty</a>(“webdriver.chrome.driver”, “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”); System.setProperty(“webdriver.chrome.driver”, “C:\driver\chrome\chromedriver.exe”); driver = new ChromeDriver(); driver.get(“<a href="https://cav.receita.fazenda.gov.br/autenticacao/login">https://cav.receita.fazenda.gov.br/autenticacao/login</a>”); ClassLoader classLoader = ClassLoader.getSystemClassLoader(); File clientSslCertificate; clientSslCertificate = new File( classLoader.getResource(“C:\Users\Lucas\Desktop\certificado\abc.pfx”).getFile());
String certificatePassword = “xxxx”; Selenium1.proxy = new SeleniumSslProxy(clientSslCertificate, certificatePassword); Selenium1.proxy.start(); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setProxy(proxy); driver = new ChromeDriver(chromeOptions); driver.findElement(By.xpath("//*[@id=“caixa-login-certificado”]")).click();
-
Saída apresentada
Starting ChromeDriver 78.0.3904.70 (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-heads/3904@{#800}) on port 12759
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[[telefone removido].976][WARNING]: Timed out connecting to Chrome, retrying…
dez 18, 2019 5:47:12 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFORMAÇÕES: Detected dialect: W3C
Exception in thread “main” java.lang.NullPointerException
at selenium1.Selenium1.main(Selenium1.java:36)
C:\Users\Lucas\AppData\Local\NetBeans\Cache\8.2\executor-snippets\debug.xml:83: Java returned: 1
FALHA NA CONSTRUÇÃO (tempo total: 35 segundos)
Desde já agradeço pela ajuda.