I am trying to upload a txt file to the web application I'm working on, through automation.The application only allows browsing and selecting the file from the local system and it doesn't allow to set the path of the file.Ruby watir-webdriver is the tool used for automating.Can someone help me in automating this.
It looks like this:
file = "/full/path/to/file.jpg"
browser.file_field(id: "upload-here").set(file)
Related
My app, Cassius, is happily using an external file (i.e not in ~/Library/Application Support/) to store webView data.
The OSX sandbox is obviously not allowing this. I thus used this GitHub project to ask the user the desired location for the file.
I can create a text file on my desktop using this, successfully going out of the sandbox, but giving a file to my WebView local storage [webPrefs _setLocalStorageDatabasePath:myDirectory]; doesn't work.
In both cases the console report an issue sandboxd: deny file-read-data...
Is there a way for a sandbox'd app to use an external file as a WebView local storage?
Thank you !
I am currently writing a Go web app using Revel.
My app needs to read the content of an XML file which is stored on the server. At the moment, I store this file in the "public" folder where some other resources (css, js...) lie.
I am using ioutil.ReadFile to read the content of this file. While this is working when the server is run from the main app folder itself, I cannot figure how to access the file when the server is run from another location (say by running "revel run myapp" from $GOPATH).
Is there any way to deal with this situation in revel?
is there a generic way to know the path of the "public" folder?
Any hint would be appreciated.
Thanks! :)
The base path of the application is stored and accessible through revel.BasePath.
The "public" folder can thus be accessed through revel.BasePath + "/public/<...>".
This BasePath value is used, for example, in Static.Serve.
so I am working on a school project in which we have designed a web application that takes in much user info and creates a pdf then should display that pdf to the user so they can print it off or save it. We are using Play! Framework 2.1.3 as our framework and server and Java for the server side. I create the pdf with Apache's PDFbox library. Every thing works as it should in development mode ie launching it on a localhost with plays run command. the issue is when we put it up to the server and launch with plays start command I it seems to take a snapshot of the directory (or at least the assets/public folder) which is where I am housing the output.pdf file/s (i have attempted to move the file elsewhere but that still seems to result in a 404 error). Initially I believed this to be something with liunx machine we were deploying to which was creating a caching problem and have tried many of the tricks to defeat the browser from caching the pdf
like using javascript to append on a time stamp to the filename,
using this cache-control directive in the play! documentation,
"assets.cache./public/stylesheets/output.pdf"="max-age=0",
then I tried to just save the pdf as a different filename each time and pass back the name of that file and call it directly through the file structure in the HTML
which also works fine with the run command but not the start.
finally I came to the conclusion that when the start command is issued it balls up the files so only the files that are there when the start command is issued can be seen.
I read the documentation here
http://www.playframework.com/documentation/2.1.x/Production
which then I noticed this part
When you run the start command, Play forks a new JVM and runs the
default Netty HTTP server. The standard output stream is redirected to
the Play console, so you can monitor its status.
so it looks like the fact that it forks a new JVM is what is causing my pain.
so my question really is can this be gotten around in some way that a web app can create and display a pdf form? (if I cannot get this to work my only solution
that I can see is that I will have to simulate the form with HTML and fill it out from there) --which I really think is a bad way to do this.
this seems like something that should have a solution but I cannot seem to find or come up with one please help.
i have looked here:
http://www.playframework.com/documentation/2.1.x/JavaStream
the answer may be in there but Im not getting it to work I am pretty novice with this Play! Framework still
You are trying to deliver the generated PDF file to the user by placing it in the assets directory, and putting a link to it in the HTML. This works in development mode because Play finds the assets in the directory. It won't work in production because the project is wrapped up into a jar file when you do play dist, and the contents of the jar file can't be modified by the Play application. (In dev mode, Play has a classpath entry for the directory. In production, the classpath points to the jar file).
You are on the right lines with JavaStream. The way forward is:
Generate the PDF somewhere in your local filesystem (I recommend the temp directory).
Write a new Action in your Application object that opens the file you generated, and serves it instead of a web page.
Check out the Play docs for serving files. This approach also has the advantage that you can specify the filename that the user sees. There is an overloaded function Controller.ok(File file, String filename) for doing this. (When you generate the file, you should give it a unique name, otherwise each request will overwrite the file from a previous request. But you don't want the user to see the unique name).
I wrote vbscript inside my html file for my site and I can't get it to work. I know it only works in internet explorer as thats the common answer I see people write with this issue. I am able to get basic vbscript working, but when trying to use filesystemobjects to open a text file nothing happens. Code being used is below.
<Script type="text/vbscript">
Dim fsobj, objtxt, thearr
Set fsobj = CreateObject("Scripting.FileSystemObject")
Set objtxt = fsobj.OpenTextFile("./subfolder/foo.txt", 1)
thearr = split(objtxt.readline, ",")
document.write(thearr(0) & " and " & thearr(1))
</script>
I get the code to work when saving with asp extension but not when I save as html, is there a way to get it to work with only using the html extension? If not does someone have an explanation as to why scripting filesystemobject without the asp extension doesn't work? I seem to can't search for the answer I'm looking for.
When you were using the FileSystemObject from an ASP page, then you were manipulating the file-system of the server. This is permitted.
However, when you use the code above, you are executing the code on the client. It is not permitted to access the clients file-system from inside Internet Explorer, as it would have serious security implications. The technical term is "sandboxing".
If you need to interact with the file-system on the client machine, you will need to use a technology such as ActiveX.
When you run the script as client script, it would try to access the file from the client computer, not the server. The file isn't there, and even if it was, your script would not be allowed to access it.
You should consider using HTML Applications by renaming your file with a .hta suffix.
An HTA executes without the constraints of the internet browser security model; in fact, it executes as a "fully trusted" application.
HTML files running inside internet browsers are considered as "untrusted" because the code comes from the internet, and is generally considered as "untrusted" as such the browser enforces a tight security model that prevents those HTML pages gaining access to your computer, which is why the FileSystemObject is unable to open the text file. However, as a HTA it is no longer being run by your browser, but via Microsoft's MSHTA application which grants your script full trust.
For more information see HTML Application - Wikipedia.
I'm making a PlayBook webworks application. I am having problems reading a local file.
I want to make an XSLT transformation using a remote XML and a local xsl file.
I am able to download an external xml file using XMLHttpRequest, but i cannot read a local file.
I tried to read it unsing the local:/// and using relative path, but always get my XMLhttprequest status response code = 0.
Any ideas?
Thanks in advance,
Jordi Gaset
Local file access in WebWorks is not supported yet as of the v1.0.0.23 Beta3 SDK.
Sadly the only way I could get this to work was to store my local data as json instead of xml, then make use of the sql lite HTML5 database to store anything inside of the app. I think the webworks sdk needs to have their own implementation of the xmlhttprequest object that gets around all of these crazy cross-domain issues. I tried for a while to use webworks, gave up, and started to use the air sdk.