Wie kommt man Selen mit PHP / Firefox3 auf Linux arbeiten
Frage
Ich versuche zu bekommen Selenium RC Arbeit mit Firefox 3 unter Linux mit PHP / Apache aber haben Probleme. Hier ist, was ich getan habe:
- Ich habe die Firefox Selenium-IDE-Erweiterung installiert.
- Auf dem Web-Server (was in meinem Fall ist eigentlich die gleiche Maschine läuft Firefox), habe ich den Selenium-Server mit gestartet: java -jar Selen-server.jar -interactive
- Ich habe ein PHP-Skript wie folgt:
PHP:
require_once 'Testing/Selenium.php';
$browser = new Testing_Selenium("*custom /usr/lib/firefox-3.0.3/firefox", "https://www.example.com");
$browser->start();
Wenn ich den PHP-Skript ausführen, einen neue Firefox Tab nicht starten, aber Ich erhalte diese Fehlermeldung :
The requested URL /selenium-server/core/RemoteRunner.html was not found on this server.
Ich habe mehr Erfolg mit Firefox 2 hatte (von "*firefox"
statt "*custom"
verwenden, aber nicht wollen, dass die für ein aktuelles Projekt verwenden.
Lösung
Ich bin mir nicht sicher, ob die Etikette Ihre eigene Frage zu beantworten ... aber in einer Trial-and-error Art und Weise experimentiert zu haben, hier ist, wie ich es geschaffen habe Selen zu bekommen mit PHP / Firefox3 auf Ubuntu arbeiten.
- I heruntergeladen RC und kopiert die PHP-Client-Verzeichnis / usr / share / php als 'Selenium'
- I zum Selenium Server-Verzeichnis navigiert im Download und begann Selen mit
java -jar selenium-server.jar
- Ich habe ein neues Firefox-Profil (von firefox -ProfileManager ausgeführt wird). Ich rief das neue Profil ‚Selenium‘
- Innerhalb dieses Profil, bearbeite ich die Firefox Netzwerkeinstellungen Proxy alle Protokolle über den Local Host-Port 4444.
-
Ich habe meinen PHP-Skript und lief es mit diesem Befehl:
php -d include_path=".:/usr/share/php:/usr/share/php/Selenium/PEAR" test.php
Ich habe meine aufgelistet (basic, nicht-PHPUnit, nicht-OO) erste Testskript unter Referenz.
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();
Andere Tipps
Ich benutze phpunit, Selen RC php api meine Testfälle zu laufen. Mein Testfall sieht aus wie
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
Dies wird an Browser verbindet innerhalb der virtuellen Maschinen