File upload 硒、PHPUnit和附件()

File upload 硒、PHPUnit和附件(),file-upload,selenium,phpunit,File Upload,Selenium,Phpunit,我目前正在通过PHPUnit向远程服务器运行Selenium命令。我遇到了一个问题,我试图将图像上传到输入表单 在我的PHPUnit中,我有命令权 $this->attachFile( 'file', 'file://test.png' ); 我的Selenium服务器返回一个错误 PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete(). java.lang.RuntimeExcep

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

在我的PHPUnit中,我有命令权

$this->attachFile( 'file', 'file://test.png' );
我的Selenium服务器返回一个错误

PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete().
java.lang.RuntimeException: Output already exists: /tmp/selenium2070373138020433468upload.
我的test.png文件当前仅位于执行.php单元测试的文件夹中


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

我也遇到了同样的问题。然后我发现了这篇文章:

因此,不要使用
$this->attachFile('文件','file://test.png)
我用过:

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

而且它是有效的!:)

我的经验:文件路径必须以
文件为前缀://
(在Windows平台上使用)。

下面的代码有效。试试看

$this->byName('Name Locator')->value('/home/img/Desert.jpg');
$this->byName()->submit();
sleep(1);

请选择正确答案。原来的问题现在已经很老了。2012年,Vitek Jezek的答案可能是正确的,但在2016年,使用phpunit selenium和Webdriver,这个答案可能就是您想要的。