Как я могу автоматически запустить веб-браузер с заданным размером окна и URL

1721
jaeyong

В Linux можно ли запустить веб-браузер с заданным размером окна и URL-адресом, используя консоль терминала или какой-либо сценарий (например, оболочку)?

Я хочу протестировать сервер веб-потоковой передачи, чтобы увидеть, сколько клиентов может транслировать видео с сервера и запустить Firefox вручную - довольно раздражающая задача.

Любые замечания будут оценены.

1

3 ответа на вопрос

3
Bob

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 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.)

Вопрос помечен Linux, но параметры измерения работают, несмотря на то, что они не перечислены `firefox --help` justbrowsing 10 лет назад 0
@justbrowsing Да, я только что заметил, что у меня был `.exe` в конце. Сила привычки. Остальное должно быть применимо к Linux, AFAIK. Bob 10 лет назад 0
Я попробовал следующие команды, и параметр измерения выглядит как не примененный: firefox -height 300 -width 200 -new-window "google" jaeyong 10 лет назад 0
Кроме того, добавление -no-remote -createprofile "test1" к аргументу не работает ..., какую настройку мне не хватает? jaeyong 10 лет назад 0
@jaeyong WorksForMe (Kubuntu, Firefox 23.0, что вы запускаете?). Вы должны создавать профили независимо от их использования; Я исправлю ответ, чтобы включить это. Bob 10 лет назад 0
`-height` и` -width`, кажется, работают, только если Firefox еще не запущен. `-new-window` открывается в новом окне, но если FF работает, он использует размеры предыдущего окна. Запуск FF 22 на Ubuntu 12.04.2 с Unity That Brazilian Guy 10 лет назад 0
0
justbrowsing

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.

0
davidgo

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)

Да, я не хочу накладывать какие-либо накладные расходы на графический интерфейс. Но все же хочу подчеркнуть нагрузку на сервер потоковым видео. Любая идея? jaeyong 10 лет назад 0
Вам нужно будет посоветовать, как вы делаете потоковую передачу, или заменить Firefox клиентом захвата потока командной строки. (Может быть, VLC может помочь вам, по крайней мере, снизить накладные расходы GUI по сравнению с браузером, или вы можете попробовать, или использовать mencoder и скопировать поток, а не конвертировать его?) davidgo 10 лет назад 0
О верно. VLC или menucoder могут помочь! Благодарю. Я не думал в этом представлении :) jaeyong 10 лет назад 0

Похожие вопросы