Pregunta

Estoy tratando de que Selenium RC funcione con Firefox 3 en Linux con PHP / Apache pero estoy experimentando problemas. Esto es lo que he hecho:

  • He instalado la extensión de Firefox Selenium-IDE.
  • En el servidor web (que en mi caso es en realidad la misma máquina que ejecuta Firefox), inicié el servidor Selenium con: java -jar selenium-server.jar -interactive
  • Tengo un script PHP de la siguiente manera:

PHP:

require_once 'Testing/Selenium.php';

$browser = new Testing_Selenium("*custom /usr/lib/firefox-3.0.3/firefox", "https://www.example.com");
$browser->start();

Cuando ejecuto el script PHP, ejecuta una nueva pestaña de Firefox, pero me aparece este mensaje de error :

The requested URL /selenium-server/core/RemoteRunner.html was not found on this server.

He tenido más éxito con Firefox 2 (al usar " * firefox " en lugar de " * custom " pero no quiero usar eso para mi proyecto actual.

¿Fue útil?

Solución

No estoy seguro de la etiqueta de responder a su propia pregunta ... pero después de experimentar de forma de prueba y error, así es como he logrado que Selenium funcione con PHP / Firefox3 en Ubuntu.

  1. Descargué RC y copié el directorio del cliente php a / usr / share / php como 'Selenium'
  2. Navegué al directorio de Selenium Server en la descarga e inicié Selenium con java -jar selenium-server.jar
  3. Creé un nuevo perfil de Firefox (ejecutando firefox -ProfileManager). Llamé al nuevo perfil 'Selenium'
  4. Dentro de ese perfil, edito las preferencias de la red de Firefox para establecer un proxy de todos los protocolos a través del puerto local 444.
  5. Creé mi script php y lo ejecuté con este comando:

    php -d include_path = ". / usr / share / php: / usr / share / php / Selenium / PEAR " test.php

He enumerado mi primer script de prueba (básico, sin unidad de PHP, sin OO) a continuación como referencia.

require_once 'Testing/Selenium.php';

$oSelenium = new Testing_Selenium(
    "*custom /usr/lib/firefox-3.0.3/firefox -P Selenium",
    "https://www.example.com");
$oSelenium->start();

$oSelenium->open("/");

if (!$oSelenium->isElementPresent("id=login_button")) {
        $oSelenium->click("logout");
        $oSelenium->waitForPageToLoad(10000);
        if (!$oSelenium->isElementPresent("id=login_button")) {
                echo "Failed to log out\n\n";
                exit;
        }
}

$oSelenium->type("login", "my_username");
$oSelenium->type("password", "my_password");
$oSelenium->click("login_button");
$oSelenium->waitForPageToLoad(10000);

$oSelenium->click("top_nav_campaigns");

$oSelenium->stop();

Otros consejos

Utilizo phpunit, selenium RC php api para ejecutar mis casos de prueba. Mi caso de prueba se parece



1235$Deepan@Newton~/selenium/ide_scripts$
cat mytest.php
 'FF on linux',
      'browser' => '*firefox',
      'host'    => '10.211.55.8',
      'port'    => 4444,
      'timeout' => 30000,
    ),
    array(
      'name'    => 'FF on windows',
      'browser' => '*firefox',
      'host'    => '10.211.55.5',
      'port'    => 4444,
      'timeout' => 30000,
    ),
     */
    array(
      'name'    => 'Google Chrome on windows',
      'browser' => '*googlechrome',
      'host'    => '10.211.55.5',
      'port'    => 4444,
      'timeout' => 30000,
    ),
    /*
    array(
      'name'    => 'IE on windows',
      'browser' => '*iexplore',
      'host'    => '10.211.55.5',
      'port'    => 4444,
      'timeout' => 30000,
    ),
    array(
      'name'    => 'Safari on MacOS X',
      'browser' => '*safari',
      'host'    => 'localhost',
      'port'    => 4444,
      'timeout' => 30000,
    ),
    array(
      'name'    => 'Firefox on MacOS X',
      'browser' => '*chrome',
      'host'    => 'localhost',
      'port'    => 4444,
      'timeout' => 30000,
    ),
     */
    array(
      'name'    => 'Google Chrome on MacOS X',
      'browser' => '*googlechrome',
      'host'    => 'localhost',
      'port'    => 4444,
      'timeout' => 30000,
    )
  );

  protected function setUp()
  {
    //$this->setBrowser("*chrome");
    $this->setBrowserUrl("http://www.facebook.com/");
  }

  public function testMyTestCase()
  {
    $this->open("/index.php?lh=94730c649368393b6954cb9fc0802e0a&eu=iKjrC7Q2aC-8tcU7PVLilg");
    $this->type("email", "myemail@domain.com");
    $this->type("pass", "mypassword");
    $this->click("persistent");
    $this->click("//input[@type='submit']");
    $this->waitForPageToLoad("30000");
    sleep(10);
    $this->open("http://apps.facebook.com/myapp/");
    sleep(4);
    $this->click("link=Play");
    $this->waitForPageToLoad("30000");
    sleep(4);
    $this->click("navAccountLink");
    sleep(4);
    $this->click("link=Logout");
    $this->waitForPageToLoad("30000");
    sleep(4);
  }
}
?>
1332$Deepan@Newton~/selenium/ide_scripts$
phpunit mytest.php

Esto se conectará a los navegadores que se ejecutan dentro de máquinas virtuales

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top