18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Uploading files with _file() into a ZK WebApp

jmt4b04d4vjmt4b04d4v Members
edited November -1 in Sahi - Open Source
Hello, first of all, congratulations for this great tool.

Although I had success at using Sahi for most of the Web automation of a particular ZK Web Application, I have not being able to get file upload to work.

I have read the _setFile reference and forums, looking for any clue, but most of the successful cases use HTML Forms and HTTP requests, so having the Sahi proxy add the files at submitting the HTTP request does work. ZK FileUpload seems to use AJAX requests to populate some server side information before the actual form submission, and apparently fails by not having "any files uploaded yet" (a funny cast attempt is performed).

I suspect that the workaround Sahi uses for handling file uploads might not be appropriate to the way ZK FileUpload handles the file upload process, but hopefully I'm wrong and a workaround exists that might be useful for me and other ZK users.

I have the following Firefox specific Sahi Script code to reproduce the problem at the ZK demo page. At www_zkoss_org\zkdemo\file_handling\file_upload (replace '_' by '.' '\' by '/', forum limitations on me) run:

_setFile(_file("file"), "c:\\tmp\\index.png");
_call(_file("file").type = "text");
_focus(_textbox("file"));
_setValue(_textbox("file"), "c:\\tmp\\index.png");

The Sahi script ends with success (no useful information at the logs), but causes an unhandled Java exception at the ZK Web Application after a little delay.

Environment information:
* OS Name: Windows Server 2003
* Browser Name/Version: Firefox 9.0.1
* Sahi Build: 2011-05-25

Regards,
-- Marvin

Comments

  • Hello,

    i'am evaluating sahi to test a web application built with zk(zkoss.org) and have the same problem as described above.

    For us the ability to upload a file using sahi is vital, since it's used in a major functionality of the web application.

    Can anyone help us out ?

    Thanks in advance.

    Best regards,
    Ricardo Gonçalves
  • narayannarayan Administrators
    Hi Ricardo,
    Can you please point to a sample website where we can test this out?
    Thanks,
    Narayan
  • Hello Narayan, new users have restrictions on publishing URLs.

    I had posted a sample URL site (with a confusing encoding maybe) in the original message (ZK's samples, "File Upload" sample).

    On a Linux box type the following in a shell to get the URL:
    $ echo aHR0cDovL3d3dy56a29zcy5vcmcvemtkZW1vL2ZpbGVfaGFuZGxpbmcvZmlsZV91cGxvYWQK | base64 --decode

    Thanks for your attention,
    --
    Marvin
Sign In or Register to comment.