Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 含硒磷肥_Php_Selenium_Phpunit_Selenium Webdriver - Fatal编程技术网

Php 含硒磷肥

Php 含硒磷肥,php,selenium,phpunit,selenium-webdriver,Php,Selenium,Phpunit,Selenium Webdriver,我正在尝试将PHPUnit与硒一起使用 我启动服务器 java-jarc:/xampp/selenium-server-standalone-2.18.0.jar 这是我的测试 require_once 'PHPUnit/Extensions/Selenium2TestCase.php'; class WebTest extends PHPUnit_Extensions_Selenium2TestCase { protected function setUp() { $this-&

我正在尝试将PHPUnit与硒一起使用

我启动服务器 java-jarc:/xampp/selenium-server-standalone-2.18.0.jar

这是我的测试

require_once 'PHPUnit/Extensions/Selenium2TestCase.php';

class WebTest extends PHPUnit_Extensions_Selenium2TestCase {
  protected function setUp() {
    $this->setBrowser("*chrome");
    $this->setBrowserUrl("http://localhost/");
  }

  public function testMyTestCase() {
    $this->url('my/url/index.php');
    $link = $this->byId('1-m-0');
    $this->assertEquals('11', $link->text());
  }
}
页上存在id为=“1-m-0”的项,但测试失败,因为它将元素获取为null。 我尝试过其他元素,SeleniumTestCase类(使用相同的服务器),但运气不好


我做错了什么?

好的,找到答案。这是我的课:

class WebTest extends PHPUnit_Extensions_SeleniumTestCase {
  protected function setUp() {
    $this->setBrowser("*firefox");
    $this->setBrowserUrl("http://localhost/");
  }

  public function testPlay() {
    $this->open('http://localhost/my/url/index.php');
    $this->waitForPageToLoad(4000);
    // Wait for ajax to load
    $this->waitForCondition("selenium.browserbot.getCurrentWindow().$('#mytable').length > 0");
    $ids = array(
      '1-m-0',
      '2-n-1',
    );
    // Click ids
    foreach ($ids as $v) {
      $xpath = "xpath=//button[@id='{$v}']";
      $this->assertElementPresent($xpath);
      $this->click($xpath);
    }
  }
}
这篇文章帮助了我:


我正在使用这个selenium服务器:selenium-server-standalone-2.18.0.jar

好的,找到了。这是我的课:

class WebTest extends PHPUnit_Extensions_SeleniumTestCase {
  protected function setUp() {
    $this->setBrowser("*firefox");
    $this->setBrowserUrl("http://localhost/");
  }

  public function testPlay() {
    $this->open('http://localhost/my/url/index.php');
    $this->waitForPageToLoad(4000);
    // Wait for ajax to load
    $this->waitForCondition("selenium.browserbot.getCurrentWindow().$('#mytable').length > 0");
    $ids = array(
      '1-m-0',
      '2-n-1',
    );
    // Click ids
    foreach ($ids as $v) {
      $xpath = "xpath=//button[@id='{$v}']";
      $this->assertElementPresent($xpath);
      $this->click($xpath);
    }
  }
}
这篇文章帮助了我:


我正在使用这个selenium服务器:selenium-server-standalone-2.18.0.jar

如果您觉得phpunit库有点混乱,我们创建了一个与selenium Json Wire协议交互的库,但我们的目标是使它尽可能与官方文档示例相似。因此,一个来自Java中selenium站点的示例在php中的语法几乎相同

请查看:

如果你喜欢,就分享它,参与其中,用叉子叉它,或者做你想做的事:)


关于这一点,马克。

如果您觉得phpunit库有点混乱,我们创建了一个与Selenium Json Wire协议交互的库,但我们的目标是使其与官方文档示例尽可能相似。因此,一个来自Java中selenium站点的示例在php中的语法几乎相同

请查看:

如果你喜欢,就分享它,参与其中,用叉子叉它,或者做你想做的事:)


注意,Mark。

waitForPageToLoad和waitForPageToLoad原因“BadMethodCallException:命令'waitForPageToLoad'不存在或尚不受支持。”它依赖于什么?waitForPageToLoad和waitForPageToLoad原因“BadMethodCallException:命令'waitForPageToLoad'不存在或尚不受支持。”这取决于什么?