Selenium,PHPUnit和AttachFile()

Dan*_*han 5 selenium phpunit file-upload

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

在我的PHPUnit中,我有命令

$this->attachFile( 'file', 'file://test.png' );
Run Code Online (Sandbox Code Playgroud)

我的Selenium服务器返回错误

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

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

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

小智 6

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

因此,而不是使用$this->attachFile('file', 'file://test.png')我已经使用过:

$this->type('file', '/path/to/file');
Run Code Online (Sandbox Code Playgroud)

它的工作原理!:)