@@ -194,6 +194,39 @@ func NewSeleniumService(jarPath string, port int, opts ...ServiceOption) (*Servi
194
194
return s , nil
195
195
}
196
196
197
+ func NewSeleniumServiceV4 (jarPath string , port int , opts ... ServiceOption ) (* Service , error ) {
198
+ s , err := newService (exec .Command ("java" ), "/wd/hub" , port , opts ... )
199
+ if err != nil {
200
+ return nil , err
201
+ }
202
+ s .cmd .Args = append (s .cmd .Args , "-jar" , jarPath )
203
+ if s .javaPath != "" {
204
+ s .cmd .Path = s .javaPath
205
+ }
206
+
207
+ var classpath []string
208
+ if s .htmlUnitPath != "" {
209
+ classpath = append (classpath , s .htmlUnitPath )
210
+ }
211
+ if s .geckoDriverPath != "" {
212
+ // s.cmd.Args = append([]string{"java", "-Dwebdriver.gecko.driver=" + s.geckoDriverPath}, s.cmd.Args[1:]...)
213
+ classpath = append (classpath , s .geckoDriverPath )
214
+ }
215
+ if s .chromeDriverPath != "" {
216
+ classpath = append (classpath , s .chromeDriverPath )
217
+ }
218
+ if len (classpath ) > 0 {
219
+ s .cmd .Args = append (s .cmd .Args , "--ext" , strings .Join (classpath , ":" ))
220
+ }
221
+ s .cmd .Args = append (s .cmd .Args , "standalone" , "--port" , strconv .Itoa (port ))
222
+ fmt .Println ("Selenium Args:" , s .cmd .Args )
223
+ if err := s .start (port ); err != nil {
224
+ return nil , err
225
+ }
226
+
227
+ return s , nil
228
+ }
229
+
197
230
// NewChromeDriverService starts a ChromeDriver instance in the background.
198
231
func NewChromeDriverService (path string , port int , opts ... ServiceOption ) (* Service , error ) {
199
232
cmd := exec .Command (path , "--port=" + strconv .Itoa (port ), "--url-base=wd/hub" , "--verbose" )
0 commit comments