GithubHelp home page GithubHelp logo

Comments (6)

chmike avatar chmike commented on August 20, 2024 1

Bug filed at bugzilla

from rod.

chmike avatar chmike commented on August 20, 2024

The following code uses os.StartProcess as go-rod and succeeds in starting an independent instance.

// From https://gist.github.com/lee8oi/ec404fa99ea0f6efd9d1
func Start(args ...string) (p *os.Process, err error) {
	if args[0], err = exec.LookPath(args[0]); err == nil {
		var procAttr os.ProcAttr
		procAttr.Files = []*os.File{os.Stdin,
			os.Stdout, os.Stderr}
		p, err := os.StartProcess(args[0], args, &procAttr)
		if err == nil {
			return p, nil
		}
	}
	return nil, err
}

func startFirefox2() {
	p, err := Start("firefox", "--profile", "/home/.../Data/nz5ijj7z.profile", "--new-instance")
	if err != nil {
		panic(err)
	}
	p.Wait()
}

Trying to start firefox with go-rod and Leakless(false) fails. I still get the error that firefox is already running. But getting the debug port given in the parameters succeeds.

from rod.

ysmood avatar ysmood commented on August 20, 2024

https://go-rod.github.io/#/compatibility?id=supported-browsers

#193

from rod.

chmike avatar chmike commented on August 20, 2024

I finally identified the cause.

Firefox ignores the argument --profile if its value is attached with =. Surprisingly, it doesn’t ignore the --remote-debugging-port=9333 argument. It does open the port 9333.

This is a limitation of firefox with the --profile parameter. There may be other parameters like that.

The following code does nearly everything like go-rod except that the profile parameter is properly separated. It then works and port 9333 is opened.

func Start(bin string, args ...string) (p *os.Process, err error) {
	cmd := exec.Command(bin, args...)
	cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
	cmd.Stdout = io.MultiWriter(io.Discard, launcher.NewURLParser())
	cmd.Stderr = io.MultiWriter(io.Discard, launcher.NewURLParser())
	err = cmd.Start()
	if err != nil {
		return
	}
	return cmd.Process, err
}

func startFirefox2() {
	p, err := Start("/usr/bin/firefox", "--new-instance", "--profile", profileDir, "--remote-debugging-port=9333")
	if err != nil {
		panic(err)
	}
	p.Wait()
}

I don’t know if there can be a quick fix to use go-rod with firefox. As I can’t test the code beyond that I don’t know.

from rod.

chmike avatar chmike commented on August 20, 2024

So apparently, firefox is not supported by go-rod because of another problem. Sorry to hear that.

from rod.

chmike avatar chmike commented on August 20, 2024

I’m in the process to fix the firefox command line limitation myself so that it will support "--option=param" arguments as needed for go-rod. The code fix is written and going through the review process.

from rod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.