Estou tentando iniciar o selênio e o servidor Xvfb X sem cabeçalho usando um script de inicialização e a ferramenta daemon.
Mas quando eu inicio meu ambiente usando esse método, o Firefox não consegue iniciar. Parece que não consegue encontrar o Firefox 2 e depois pára. Quando inicio esse ambiente normalmente, ele também não encontra o Firefox 2, mas depois procura o Firefox 3, o encontra e inicia corretamente.
Este é o meu script de inicialização:
#!/bin/bash
#
# Starts a Selenium-RC headless environment
# License: https://github.com/amenk/SelfScripts/blob/master/LICENSE.md
#
# BETA
# Fixmes:
# - We should take care of running the environment under a non-priviledged user
#
# Source function library.
. /lib/lsb/init-functions
LOG=/var/log/selenium.log
DISPLAY_NO=99
JAVA=/usr/bin/java
XVFB=/usr/bin/Xvfb
SELENIUM_JAR=/opt/selenium-server-standalone-2.20.0.jar
FIREFOX_TEMPLATE=/home/amenk/.mozilla/firefox/aph73r3f.selenium/
start() {
log_daemon_msg "Starting Xvfb"
daemon --dbglog=$LOG --errlog=$LOG --stdout=$LOG --stderr=$LOG\
--name Xvfb -- $XVFB :$DISPLAY_NO -ac -screen 0 1024x768x8
log_end_msg $?
log_daemon_msg "Starting Selenium RC"
daemon --dbglog=$LOG --errlog=$LOG --stdout=$LOG --stderr=$LOG\
--name Selenium-RC --env=DISPLAY=$DISPLAY_NO\
-- java -jar $SELENIUM_JAR -log /var/log/selenium-debug.log -browserSideLog -firefoxProfileTemplate $FIREFOX_TEMPLATE
log_end_msg $?
return
}
stop() {
log_daemon_msg "Stopping Selenium RC"
daemon --stop --name Selenium-RC
log_end_msg $?
log_daemon_msg "Stopping Xvfb"
daemon --stop --name Xvfb
log_end_msg $?
return
}
status() {
daemon -v10 --running --name Xvfb
daemon -v10 --running --name Selenium-RC
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "Usage: {start|stop|status|reload|restart[|probe]"
exit 1
;;
esac
exit $?
Começar tudo funciona bem, mas quando executo um teste de selênio no servidor, recebo a seguinte mensagem em /var/log/selenium-debug.log:
13:21:29.207 DEBUG [11] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Discovering Firefox 2...
13:21:29.207 DEBUG [11] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Checking whether Firefox 2 launcher at :'/Applications/Minefield.app/Contents/MacOS/firefox-bin' is valid...
13:21:29.207 DEBUG [11] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Checking whether Firefox 2 launcher at :'/Applications/Firefox-2.app/Contents/MacOS/firefox-bin' is valid...
13:21:29.207 DEBUG [11] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Checking whether Firefox 2 launcher at :'/Applications/Firefox.app/Contents/MacOS/firefox-bin' is valid...
13:21:29.207 DEBUG [11] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Checking whether Firefox 2 launcher at :'/usr/lib/firefox/firefox-bin' is valid...
13:21:29.209 INFO [11] org.openqa.selenium.server.SeleniumDriverResourceHandler - Got result: Failed to start new browser session: java.lang.NullPointerException on session null
Quando eu executo selênio e xvfb com os mesmos parâmetros sob o mesmo usuário, eu obtenho
...
13:31:16.413 DEBUG [11] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Checking whether Firefox 2 launcher at :'/usr/lib/firefox/firefox-bin' is valid...
13:31:16.414 DEBUG [11] org.openqa.selenium.browserlaunchers.locators.CombinedFirefoxLocator - Did not find Firefox 2, now discovering Firefox 3...
13:31:16.415 DEBUG [11] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Discovering Firefox 3...
13:31:16.433 DEBUG [11] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Checking whether Firefox 3 launcher at :'/usr/lib/firefox-addons/firefox-bin' is valid...
13:31:16.434 DEBUG [11] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Checking whether Firefox 3 launcher at :'/usr/lib/firefox-addons/firefox' is valid...
13:31:16.434 DEBUG [11] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Checking whether Firefox 3 launcher at :'/usr/lib/firefox-11.0/firefox-bin' is valid...
13:31:16.434 DEBUG [11] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Checking whether Firefox 3 launcher at :'/usr/lib/firefox-11.0/firefox' is valid...
13:31:16.434 DEBUG [11] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Discovered valid Firefox 3 launcher : '/usr/lib/firefox-11.0/firefox'
13:31:16.435 INFO [11] org.openqa.selenium.server.BrowserSessionFactory - Allocated session cb49662833c84b6cb62fcd5a4a7e9f61 for http://example.com/foo/bar/, launching...