File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
examples/java/src/test/java/dev/selenium/drivers Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,30 @@ public void remoteWebDriverIgnoreSSL() throws Exception {
70
70
driver .quit ();
71
71
}
72
72
73
+ @ Test
74
+ public void remoteWebDriverWithEmbedAuthUrl () throws Exception {
75
+ ClientConfig clientConfig = ClientConfig .defaultConfig ()
76
+ .withRetries ()
77
+ .sslContext (createSSLContextWithCA (Path .of ("src/test/resources/tls.crt" ).toAbsolutePath ().toString ()))
78
+ .connectionTimeout (Duration .ofSeconds (300 ))
79
+ .readTimeout (Duration .ofSeconds (3600 ))
80
+ .version (HTTP_1_1 .toString ());
81
+ ChromeOptions options = new ChromeOptions ();
82
+ options .setEnableDownloads (true );
83
+ driver = RemoteWebDriver .builder ()
84
+ .oneOf (options )
85
+ .address (embedAuthToUrl (gridUrl , "admin" , "myStrongPassword" ))
86
+ .config (clientConfig )
87
+ .build ();
88
+ driver .quit ();
89
+ }
90
+
91
+ private URL embedAuthToUrl (URL url , String username , String password ) throws Exception {
92
+ String userInfo = username + ":" + password ;
93
+ String urlWithAuth = url .getProtocol () + "://" + userInfo + "@" + url .getHost () + ":" + url .getPort () + url .getPath ();
94
+ return new URL (urlWithAuth );
95
+ }
96
+
73
97
public static SSLContext createSSLContextWithCA (String caCertPath ) throws Exception {
74
98
FileInputStream fis = new FileInputStream (caCertPath );
75
99
CertificateFactory cf = CertificateFactory .getInstance ("X.509" );
You can’t perform that action at this time.
0 commit comments