PHP Capture从PHP中的计算函数返回值

时间:2013-11-19 11:36:13

标签: php selenium eval

我正在使用facebook php-webdriver进行网络应用测试。 webdriver中有一个函数,如下所示

$webdriver->wait($timeOut, $pollInterval)->until(
    //condition to wait
); 

此“等待条件”作为方法传递;

$val = WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::id("user"))

所以完整的代码块就像;

$webdriver->wait($timeOut, $pollInterval)->until(
    $val = WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::id("user"))
); 

然后我有其他方法,如;

function get($url, [few more params], $expectedCondition){
    //do some work here and execute below wait condition
    $webdriver->wait($timeOut, $pollInterval)->until(
        $expectedCondition //this executes fine
    ); 
}

我将调用上述方法如下;     get([other params],WebDriverExpectedCondition :: presenceOfElementLocated(WebDriverBy :: id(“user”))

正如您所看到的,上面的最后一个参数是我自己的GET方法中的方法调用。它将正确执行,如下所示

    $webdriver->wait($timeOut, $pollInterval)->until(
        $expectedCondition //this will basically executes WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::id("user")) properly
    );  

但是在执行$ expectedCondition之后我无法获得返回值。

eval()不起作用

1 个答案:

答案 0 :(得分:0)

$return_value = $driver->wait()->until($expectedCondition)
相关问题