Selenium,PHPUnit和AttachFile() [英] Selenium, PHPUnit, and AttachFile()

查看:76
本文介绍了Selenium,PHPUnit和AttachFile()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在通过PHPUnit将Selenium命令运行到远程服务器.我在尝试将图像上传到输入表单时遇到了问题.

I am currently running Selenium commands through PHPUnit to a remote server. I've run into a problem where I am trying to upload an image to an input form.

在我的PHPUnit中,有命令

In my PHPUnit, I have the command

$this->attachFile( 'file', 'file://test.png' );

我的Selenium服务器返回错误

My Selenium server returns an error

PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete().
java.lang.RuntimeException: Output already exists: /tmp/selenium2070373138020433468upload.

我的test.png文件当前仅位于执行我的.php单元测试的文件夹中.

My test.png file is currently only located in the folder where I am executing my .php unit tests from.

如何通过PHPUnit和Selenium正确上传文件,并使其不引发异常?

How can I properly upload a file through PHPUnit and Selenium and get it to not throw an exception?

推荐答案

我遇到了同样的问题.然后我找到了这篇文章: http://bitsilearn.blogspot.com/2010 /03/selenium-upload-files.html

I had same problem. Then I found this article: http://bitsilearn.blogspot.com/2010/03/selenium-upload-files.html

所以我没有使用$this->attachFile('file', 'file://test.png'),而是使用了:

So instead of using $this->attachFile('file', 'file://test.png') i have used:

$this->type('file', '/path/to/file');

它有效! :)

这篇关于Selenium,PHPUnit和AttachFile()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆