Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PID method to service #7

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
// ServiceOption configures a Service instance.
type ServiceOption func(*Service) error

const InvalidPid = -1

// Display specifies the value to which set the DISPLAY environment variable,
// as well as the path to the Xauthority file containing credentials needed to
// write to that X server.
Expand Down Expand Up @@ -164,6 +166,15 @@ func (s Service) FrameBuffer() *FrameBuffer {
return s.xvfb
}

//PID returns the service pid
func (s Service) PID() int {
if s.cmd != nil {
return s.cmd.Process.Pid
}

return InvalidPid
}

// NewSeleniumService starts a Selenium instance in the background.
func NewSeleniumService(jarPath string, port int, opts ...ServiceOption) (*Service, error) {
s, err := newService(exec.Command("java"), "/wd/hub", port, opts...)
Expand Down