Selenium, PHPUnit, and AttachFile ()

I am currently running Selenium commands through PHPUnit on a remote server. I have a problem when I try to upload an image to the input form.

In my PHPUnit, I have a command

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

My Selenium server returns an error

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

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

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

+5
source share
3 answers

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

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

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

!:)

+6

: file:// ( Windows).

+1

Below is the code. Give it a try.

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

All Articles