I am using Mink and Sahi for my user interface tests inside a Symfony2 application. But actually I can't manage to upload a file with Sahi.
My Sahi server is up and running:
[09:51:33] coil@ubuntu:~/Webdev/sahi/bin$ ./sahi.sh
--------
SAHI_HOME: ..
SAHI_USERDATA_DIR: ../userdata
SAHI_EXT_CLASS_PATH:
--------
Sahi properties file = /home/coil/Webdev/sahi/config/sahi.properties
Sahi user properties file = /home/coil/Webdev/sahi/userdata/config/userdata.properties
Added shutdown hook.
>>>> Sahi started. Listening on port: 9999
>>>> Configure your browser to use this server and port as its proxy
>>>> Browse any page and CTRL-ALT-DblClick on the page to bring up the Sahi Controller
-----
Reading browser types from: /home/coil/Webdev/sahi/userdata/config/browser_types.xml
-----
My step implementation:
// $element->getXpath() --> (//html/descendant-or-self::*[@id = 'attachment'])[1]
$element->attachFile($file);
Note here that if I use a file that is not /home/coil/Webdev/sahi/userdata
directory, I get the following error:
$element->attachFile('toto');
error:_setFile2(_byXPath("(//html/descendant-or-self::*[@id = 'attachment'])[1]"), "toto")
Error: File not found: toto; Base directory is userdata directory: /home/coil/Webdev/sahi/userdata
Error: File not found: toto; Base directory is userdata directory: /home/coil/Webdev/sahi/userdata
at Sahi._setFile (http://dev.project.com/_s_/spr/concat.js:1398:12)
at Sahi._setFile2 (http://dev.project.com/_s_/spr/concat.js:1367:7)
at eval (eval at <anonymous> (http://dev.project.com/_s_/spr/concat.js:3480:14), <anonymous>:1:7)
at Sahi.ex (http://dev.project.com/_s_/spr/concat.js:3480:9)
at <anonymous>:1:11
<a href='/_s_/dyn/Log_getBrowserScript?href=null&n=-1'><b>Click for browser script</b></a>
So, Sahi can "find" the file as it doesn't raise any error with a valid and existing file. But when the form is submitted, the file is never uploaded by the Sahi proxy.
Other checks:
sahi_11a83f8806be8046fc0aaa80eac076110b95__fr-fr-2-0.bdic
What is really weird, is that I am sure that those tests passed some times ago, something must have changed in my application or configuration that breaks the Sahi file upload but I can't find what. And before in the Sahi console I had logs about the files that it was uploading, now there is no log at all.
Use absolute system path to which Sahi server has access.
Is the url to which the form is posted different from the url of the web page? _setFile and _setFile2 take a third parameter which can be configured to point to the action URL (the url to which the file should be attached by the Sahi Proxy) http://sahi.co.in/w/_setFile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With