如何访问 PHPUnit_Extensions_SeleniumTestCase 中的存储值
如何在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个帖子中的帖子很好,但到目前为止似乎还没有 100% 有效的答案。
基于此处的 Selenium 参考
http://release.seleniumhq.org/selenium -core/1.0/reference.html#storedVars
正确的代码语法似乎是:
我还没有完全测试过,但是做类似的事情对
我来说是成功的。
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:
I haven't tested that exactly, but doing something similar with
did the trick for me.
PHPUnit Selenium Testcase 驱动程序实际上理解
storeExpression
和getExpression
;看一下它的源代码。你可以做并且
The PHPUnit Selenium Testcase driver actually understands
storeExpression
andgetExpression
; have a look at its source code. You can doand
由于 Selenium 将表达式结果存储在第二个参数中,因此它将值存储在“bar”中,当您需要调用它时,您应该调用存储的名称来获取表达式。
希望这对你有帮助,它对我有用。
编辑:
第一个评估将给出表达式的评估输出
第二个将显示表达的输出。
秒用于验证警报是否生成指定的表达式。
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.
May this helps you it worked for me.
EDIT :
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.