开发者

I can't make my simple Selenium test work on any browser

开发者 https://www.devze.com 2023-04-09 14:50 出处:网络
I have a very simple and classic installation: Windows 7 WampServer with PEAR (PHP 5.3.5) PHPUnit and Selenium installed from PEAR

I have a very simple and classic installation:

  • Windows 7
  • WampServer with PEAR (PHP 5.3.5)
  • PHPUnit and Selenium installed from PEAR
  • Netbeans plugin "Selenium Module for PHP"
开发者_如何学Go

I'm trying to run the following test:

<?php
require_once 'PHPUnit/Extensions/SeleniumTestCase.php';

class WebTest extends PHPUnit_Extensions_SeleniumTestCase
{
    protected function setUp()
    {
        $this->setBrowser('*googlechrome');
        $this->setBrowserUrl('http://www.google.com');
    }

    public function testTitle()
    {
        $this->open('http://www.google.com');
    }
}
  • With *googlechrome, I get the error : "Cannot call method 'indexOf' of undefined".
  • With *firefox, I get no error but a blank firefox page, and nothing happens.
  • With *opera, it's almost fine : the page "google.com" is opened but does not loaded completely (missing one element of five) and the test fails after 30 seconds
  • With *safari, the test starts (Safari and the Selenium window are opened) but that's it...
  • I don't even want to try on Internet Explorer...


You could try defining the path to the browser. For example

"*firefox C:\\Program Files\\Mozilla Firefox\\firefox.exe"

instead of just "*firefox"


I finally understood my (stupid) error !

I just, somehow, installed a quite old version of the Selenium Server, absolutely unable to deal with recent browsers. The solution is obvious then : I updated my Selenium Server (by downloading the most recent .jar file there : http://seleniumhq.org/download/) and it all worked well !

0

精彩评论

暂无评论...
验证码 换一张
取 消