【问题标题】:codeception - transfer variable in executeInSelenium methodcodeception - 在 executeInSelenium 方法中传输变量
【发布时间】:2014-09-24 18:02:53
【问题描述】:

Codeception 有一个执行 selenium 函数的方法。我需要在一个函数中传输一个带有站点名的变量,该函数执行这个方法,所以我的代码

$I->executeInSelenium(function(\WebDriver $webdriver) {
  $webdriver->get('http://google.com');
});

可能看起来像这样:

$I->goToSite('http://google.com');

【问题讨论】:

    标签: php selenium-webdriver codeception


    【解决方案1】:

    好吧,我一定错过了关于 PHP 闭包的文章。 所以,从PHP 5.3 我可以使用闭包来做到这一点:

    $I->executeInSelenium(function(\WebDriver $webdriver) use ($url) {
    $webdriver->get($url);
    });
    

    但这种需求将被弃用,因为从 Codeception 2.0.6 方法 AmOnPage()(以及从 2.0.7 - AmOnUrl())接受绝对 URL。

    【讨论】:

      猜你喜欢
      • 2016-11-05
      • 2015-12-18
      • 2018-11-05
      • 1970-01-01
      • 1970-01-01
      • 2012-11-11
      • 2014-10-20
      • 1970-01-01
      • 2015-11-04
      相关资源
      最近更新 更多