如何访问 PHPUnit_Extensions_SeleniumTestCase 中的存储值

发布于 2024-11-12 01:34:34 字数 766 浏览 1 评论 0原文

如何在 Selenium-RC 中存储值(通过 PHPUnit),然后使用 PHPUnit 检索/访问它?

假设我在测试中运行如下命令:

$this->storeExpression( "foo", "bar" );

如果我正确理解 Selenium API 文档,我可以使用 javascript{storedVars['foo']} 使用良好的“ol 时尚 Selenese”访问此数据。它应该包含值“bar”

我的问题是:如何在 PHPUnit 中访问此 javascript{storedVars['test']} 表达式(或者更一般地说,javascript{storedVars}

例如,这是我运行的一个简单测试:

public function testStorage()
{
    $this->open('http://www.google.com/'); // for example
    $this->storeExpression( 'foo', 'bar' );
    $foo = $this->getExpression('foo');
    echo $foo;
}

其输出是“foo”(在其他标准 PHPUnit 输出中),而我希望它应该是“bar”,它只是返回表达式的名称,而不是它的值。 .

任何人都可以与 这方面的经验能给我一些指导吗?

How can I store a value within Selenium-RC (through PHPUnit) and then retrieve/access it later using PHPUnit?

Suppose I run a command like the following in a test:

$this->storeExpression( "foo", "bar" );

If I understand the Selenium API documentation correctly, I could access this data using javascript{storedVars['foo']} using good 'ol fashioned Selenese. It should contain the value "bar".

My question is this: how can I access this javascript{storedVars['test']} expression (or, more generally, javascript{storedVars} in PHPUnit?

For example, here's a simple test I've run:

public function testStorage()
{
    $this->open('http://www.google.com/'); // for example
    $this->storeExpression( 'foo', 'bar' );
    $foo = $this->getExpression('foo');
    echo $foo;
}

The output of which is "foo" (among the other standard PHPUnit output), while I expect it should be "bar". It's just giving me back the name of the expression, not its value.

Can anyone with experience in this give me some guidance?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

流云如水 2024-11-19 01:34:34

这个帖子中的帖子很好,但到目前为止似乎还没有 100% 有效的答案。

基于此处的 Selenium 参考

http://release.seleniumhq.org/selenium -core/1.0/reference.html#storedVars

正确的代码语法似乎是:

$this->storeExpression( 'bar', 'foo' );
$foo = $this->getExpression("\${foo}");

我还没有完全测试过,但是做类似的事情对

$this->storeHtmlSource('srcTxt');
$val = $this->getExpression('\${srcTxt}');
print $val;

我来说是成功的。

Good posts in this thread, but looks like no 100% working answer so far.

Based on the Selenium reference here

http://release.seleniumhq.org/selenium-core/1.0/reference.html#storedVars

It would seem the correct code syntax would be:

$this->storeExpression( 'bar', 'foo' );
$foo = $this->getExpression("\${foo}");

I haven't tested that exactly, but doing something similar with

$this->storeHtmlSource('srcTxt');
$val = $this->getExpression('\${srcTxt}');
print $val;

did the trick for me.

渔村楼浪 2024-11-19 01:34:34

PHPUnit Selenium Testcase 驱动程序实际上理解 storeExpressiongetExpression;看一下它的源代码。你可以做

$this->storeExpression('foo', 'bar');

并且

$this->getExpression('foo');

The PHPUnit Selenium Testcase driver actually understands storeExpression and getExpression; have a look at its source code. You can do

$this->storeExpression('foo', 'bar');

and

$this->getExpression('foo');
北陌 2024-11-19 01:34:34

由于 Selenium 将表达式结果存储在第二个参数中,因此它将值存储在“bar”中,当您需要调用它时,您应该调用存储的名称来获取表达式。

    $this->storeExpression( 'foo', 'bar' );
    $foo = $this->getExpression("bar");

希望这对你有帮助,它对我有用。

编辑:

    $evaluated = $this->getEval("regex:3+3");
    $expressed = $this->getExpression("regex:3+3");

第一个评估将给出表达式的评估输出
第二个将显示表达的输出。
秒用于验证警报是否生成指定的表达式。

As Selenium Stores the expression result in second argument it stores value in "bar" and when u need to call it you should call the stored name to get the expression.

    $this->storeExpression( 'foo', 'bar' );
    $foo = $this->getExpression("bar");

May this helps you it worked for me.

EDIT :

    $evaluated = $this->getEval("regex:3+3");
    $expressed = $this->getExpression("regex:3+3");

The First Evaluated will give the evaluated output for expression
and the second will show the expressed output.
The secound is used to verify that the specified expression is genrated or not by the alert.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文