代码之家  ›  专栏  ›  技术社区  ›  theazureshadow

Selenium在命令之间花费>分钟

  •  3
  • theazureshadow  · 技术社区  · 15 年前

    硒似乎在每一步之间停顿了大约一分钟(我看不到少于60秒)。即使是简单的步骤(如setspeed)也以相同的速率运行。

    但是,当我使用phpunit_扩展名seleniumtestcase类时,我能够以正常速度运行测试。(同样,在同事的电脑上,慢步骤运行良好。)

    有人知道我做错了什么吗?谢谢!

    下面是慢测试:

    debug_time(); // 0
    
    require_once 'Testing/Selenium.php';
    debug_time(); // 1
    
    $s = new Testing_Selenium('*firefox', "http://google.com/");
    debug_time(); // 2
    
    $s->setSpeed(0);
    debug_time(); // 3
    
    $s->start();
    debug_time(); // 4
    
    var_export($s->getSpeed());
    echo "\n";
    debug_time(); // 5
    
    $s->open('/');
    debug_time(); // 6
    
    $s->stop();
    debug_time(); // 7
    
    echo "done";
    

    以下是慢测试的输出:

    0 => 18:01:54.44488 (+ 0.00000)
    1 => 18:01:54.45478 (+ 0.00990)
    2 => 18:01:54.45645 (+ 0.00167)
    3 => 18:02:54.97334 (+ 60.51688)
    4 => 18:04:03.59346 (+ 68.62013)
    NULL
    5 => 18:05:04.11214 (+ 60.51867)
    6 => 18:06:05.83747 (+ 61.72534)
    7 => 18:07:06.63492 (+ 60.79744)
    done
    

    以下是从phpunit手册中获取的快速测试:

    require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
    
    class WebTest extends PHPUnit_Extensions_SeleniumTestCase
    {
        protected function setUp()
        {
            $this->setBrowser('*firefox');
            $this->setBrowserUrl('http://google.com/');
        }
    
        public function testTitle()
        {
            $this->open('/');
            $this->assertTitleEquals('Example Web Page');
        }
    }
    
    1 回复  |  直到 15 年前
        1
  •  2
  •   user491697    15 年前