문제

나는 얻으려고 노력하고있다 셀레늄 RC PHP/Apache를 사용하여 Linux에서 Firefox 3과 함께 작업하지만 문제가 발생합니다. 내가 한 일은 다음과 같습니다.

  • Firefox Selenium-ide Extension을 설치했습니다.
  • 웹 서버 (필자의 경우 실제로 Firefox를 실행하는 동일한 기계 인 경우)에서 java -jar selenium -server.jar -interctive를 사용하여 Selenium 서버를 시작했습니다.
  • 다음과 같이 PHP 스크립트가 있습니다.

PHP :

require_once 'Testing/Selenium.php';

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

PHP 스크립트를 실행하면 새로운 Firefox 탭을 시작하지만 이 오류 메시지가 표시됩니다:

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

나는 Firefox 2로 더 많은 성공을 거두었습니다 (사용하여 "*firefox" 대신에 "*custom" 그러나 현재 프로젝트에 사용하고 싶지는 않습니다.

도움이 되었습니까?

해결책

나는 당신 자신의 질문에 대답하는 에티켓을 확신하지 못하지만 ... 시행 착오적인 방식으로 실험 한 결과, 셀레늄이 Ubuntu에서 PHP/Firefox3와 함께 작동하도록하는 방법은 다음과 같습니다.

  1. RC를 다운로드하고 PHP 클라이언트 디렉토리를/usr/share/php에 'selenium'으로 복사했습니다.
  2. 다운로드에서 Selenium Server 디렉토리로 탐색하고 Selenium을 시작했습니다. java -jar selenium-server.jar
  3. 새로운 Firefox 프로필을 만들었습니다 (Firefox -ProfileManager를 실행하여). 나는 새로운 프로필을 '셀레늄'이라고 불렀다.
  4. 이 프로파일 내에서 LocalHost Port 4444를 통해 모든 프로토콜을 프록시하기 위해 Firefox 네트워크 기본 설정을 편집합니다.
  5. PHP 스크립트를 만들어이 명령으로 실행했습니다.

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

아래에 (기본, 비자기, 비 OO) 첫 번째 테스트 스크립트를 참조 할 것을 나열했습니다.

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();

다른 팁

PHPUNIT, SELENIUM RC PHP API를 사용하여 테스트 케이스를 실행합니다. 내 테스트 케이스는 모양입니다



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

이것은 가상 머신 내부에서 실행되는 브라우저에 연결됩니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top