How can I launch web browser automatically with given window size and url

How can I launch web browser automatically with given window size and url

In linux, is it possible to launch web browser with given window size and url using terminal console or some kind of script (e.g., shell)?

What I want to do is to test the web streaming server to see how many clients can video-stream from the server and manually launch firefox is quite annoying task.

Any comments would be appreciated.

Antwort1

Firefox supports command-line arguments to specify URL, height and width. For example:

firefox -height 600 -width 800 "example.com"

Depending on your setup, that might actually open in new tabs. Use -new-window "example.com" to force a new window.

Do note that these windows will actually launch under a single process, reusing one if FF is already open. Apparently, setting the size will not work unless you're starting a new process (see the comments). You must specify -no-remote in order to launch multiple independent processes, and each must use a different profile, which you can specify with -p "profilename". Profiles must be created before use.

For example, if you were to do this in a loop (bash):

for i in {1..10}
do
    firefox -no-remote -createprofile testprofile$i
    firefox -no-remote -p testprofile$i -height 600 -width 800 "example.com"&
done

(The & is at the end to run it in the backround, i.e. don't wait for it to close.)

Antwort2

The question is unclear. Is this what you are asking?

firefox --no-remote -P testing http://my-url

  • You can just launch Firefox with firefox command
  • --no-remote tells it to launch a new instance
  • -P testing tells it to use a profile you named testing
  • URL opens instance with given URL

As far as the window size requirement, most Window Managers will remember the previous size of the window.

Antwort3

I can't advise on sizing the browser, but you can launch a firefox instance by simply typing

firefox "url"

From a command line.

So if you want to launch, for example, 10 instances you could write a 1 liner to launch multiple tabs to the same url :

for each in `seq 1 10`; do firefox ; done

I suspect that there are better ways of performance testing the site which don't require a browser, but I'm not an expert when it comes to streaming. WGET and CURL provide command line functionality for getting web pages and may provide a more objective result (I'm guessing you are not wanting to benchmark the browser, and a GUI has a much higher overhead)

verwandte Informationen