dongxu1029
dongxu1029
2011-09-28 12:34

我无法在任何浏览器上进行简单的Selenium测试

已采纳

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"

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...
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • dongzhui2636 dongzhui2636 10年前

    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 !

    点赞 评论 复制链接分享
  • dongyue0263 dongyue0263 10年前

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

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

    instead of just "*firefox"

    点赞 评论 复制链接分享

相关推荐