Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy can't Selenium RC see a site on virtual machine
    text
    copied!<p>I'm having trouble getting Selenium to see sites hosted on a virtual machine. The following test causes an error, and I have no idea why:</p> <pre><code>&lt;?php require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; class ActualTest extends PHPUnit_Extensions_SeleniumTestCase { protected function setUp() { $this-&gt;setBrowser("*firefox"); $this-&gt;setBrowserUrl("http://10.48.77.48/"); // IP of virtual machine $this-&gt;setHost('192.168.101.1'); // IP of my Mac } public function testGetHomePage() { $this-&gt;open("/", true); } } </code></pre> <p>It returns the following error message, indicating that it couldn't find the virtual machine:</p> <pre><code>$ phpunit ActualTest.php PHPUnit 3.5.6 by Sebastian Bergmann. E Time: 7 seconds, Memory: 6.75Mb There was 1 error: 1) ActualTest::testGetHomePage PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete(). XHR ERROR: URL = http://10.48.77.48/ Response_Code = 404 Error_Message = Page Not Found. /home/craiga/ombudsman/app/systemtests/ActualTest.php:16 FAILURES! Tests: 1, Assertions: 0, Errors: 1. </code></pre> <p>I can access this site any browser anywhere on the network without any problem, but for some reason the browser launched by Selenium can't. This error occurs whether I launch the test from the virtual machine or the Mac.</p> <p>I can get the following test to connect to Google without any problem:</p> <pre><code>&lt;?php require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; class VanitySearchTest extends PHPUnit_Extensions_SeleniumTestCase { protected function setUp() { $this-&gt;setBrowser("*firefox"); $this-&gt;setBrowserUrl("http://www.google.com.au/"); $this-&gt;setHost('192.168.101.1'); // IP of my Mac } public function testSearchForSelf() { $this-&gt;open("/"); $this-&gt;type("q", "craig anderson"); $this-&gt;click("btnG"); $this-&gt;waitForPageToLoad("30000"); try { $this-&gt;assertTrue($this-&gt;isTextPresent("craiga.id.au")); } catch (PHPUnit_Framework_AssertionFailedError $e) { array_push($this-&gt;verificationErrors, $e-&gt;toString()); } } } </code></pre> <p>This test, which connects to my Mac's default page, also passes without any problems:</p> <pre><code>&lt;?php require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; class MacTest extends PHPUnit_Extensions_SeleniumTestCase { protected function setUp() { $this-&gt;setBrowser("*firefox"); $this-&gt;setBrowserUrl("http://192.168.101.1/"); $this-&gt;setHost('192.168.101.1'); // IP of my Mac } public function testMacHomePage() { $this-&gt;open("/"); try { $this-&gt;assertTrue($this-&gt;isTextPresent("It works!")); } catch (PHPUnit_Framework_AssertionFailedError $e) { array_push($this-&gt;verificationErrors, $e-&gt;toString()); } } } </code></pre> <p>Does anyone have any idea why this might be happening? I'm happy to provide whatever information I can about my setup. I'm using Selenium Server 1.0.3, and the latest phpunit from pear.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload