So I have hit a bit of a snag. I am trying to automate a test case where I need to pass multiple files to an input node and I cannot figure out how to do so. I can use either Mechanize or Watir, but have found very little information on a topic that seems relatively major in automation. In the snippets below, I'm using Watir with Ruby. The main issue I'm having is that it seems when multiple files are selected, the input node is no longer visible. The input node does accept multiple files, and passing in a single path does result in a successful upload, like so.
path1 = "/path/to/file.json"
file_field.set path1
I would think that passing in multiple files would be as simple as passing in a string with multiple paths separated by some sort of delimiter. I'm not particularly savvy with web dev however, and am struggling to grasp where I should even start. When I attempt to pass in multiple files like so:
multiple_paths = ("/path/to/file1.json"; "/path/to/file2.json")
file_field.set multiple_paths
it gives uploads the second file but not the first (making me think maybe it's uploading them in sequence, and the second is overwriting).
Do you think this is even possible using Watir? I know that Chrome has a workaround for uploading multiple files using \n as the delimiter, is there a similar workaround for Firefox?
Currently there doesn't seem to be a workaround for Firefox. If anybody knows of one, please post the answer as I couldn't find a solution anywhere. I figured I'd post the solution for Chrome here because resources are scarce on this.
If you need to test for multiple file uploads, have that particular instance load the Chrome driver with:
#browser = Watir::Browser.new :chrome, :prefs => profile
Then you're going to want to pass it a string that looks something like this:
paths = "path/to/first/file.json\npath/to/second/file.json\n...etc
file_field.send_keys paths
Related
Is it possible to loop through a list of words in R that can each be generated into separate “speech” files using the speech2text website?
https://www.text2speech.org/
To make one file manually one has to type in the text one one page then submit it. A second page then opens with the option to download the file. Since I want to do many of these I would like to find a way to automate it. I have no idea how to approach this idea though.
EDIT
So I am using "say" on mac based on a the helpful comments. I am running it through R using a loop for all strings in a vector
for(i in 1:nrow(test[1:5])){
system("say", intern =F,input = test$English[i])%>%saveRDS(paste0("/Users/Desktop/tts/", test$English[i],".aiff"))
}
This creates the files as expected in the expected location but the .aiff files won't play in any media player. Does anyone see what I am doing wrong?
Consider using a CLI based solution for TTS, like espeak/espeak-ng (cross-platform), festival (linux), say (osx) or via powershell on windows (here's a script). Looks like the page you're referencing is using flite, which is a lightweight (and downloadable) version of festival.
I see that this has been asked here before, but nothing since Meteor.http has been available. I'm still grasping the concepts of Meteor and file uploads are totally eluding me.
Here's my question:
So, in what I believe to be the right method,
Meteor.http.call("POST", url, [options], [asyncCallback]) what do you put for the url? With the client/server javascript relationship in meteor, it doesn't seem like it really uses urls that much.
If anyone has a basic example of a file upload in meteor, that would just be extra awesome.
well been playing a bit with meteor. Made a collectionFS a mix of meteor and gridFS (could be compatible).
Test it here: http://collectionfs.meteor.com/
It support quit large files, multiple files, users etc. I've tested a 50Mb seems ok, if connection is lost or browser dies the user can resume upload.
It should even be possible to have multiple users upload to exact same file - haven't quit found a usecase for it, but it's possible.
Accounts, publishing etc. is as with collections - the test is in autopublish mode, though only meta data is avaliable - chunks of data is served in background via blobs.
I'll try getting it on github,
Take a look at filepicker.io. They handle the upload, store it into your S3, and return to you the url that you can dump into your db.
Wget the filepicker script into your client folder.
wget https://api.filepicker.io/v0/filepicker.js
Insert a filepicker input tag
<input type="filepicker" id="attachment">
In the startup, initialize it:
Meteor.startup( function() {
filepicker.setKey("YOUR FILEPICKER API KEY");
filepicker.constructWidget(document.getElementById('attachment'));
});
Attach a event handler
Template.templateNameHere.events({
'change #attachment': function(evt){
console.log(evt.files);
}
});
(I had posted on How would one handle a file upload with Meteor? Sorry. I'm new here. Is it kosher to copy the same answer twice? Anyone who knows better can feel free to edit this.)
Checkout how to accomplish this using Meteor.Method on the server and the FileReader's api on the client
https://gist.github.com/dariocravero/3922137
After several searches, this looks to me the easiest (and for the moment the meteor's style way) to handle a file upload with no extra dependencies.
Since meteor includes JQuery by default, you can utilize a Jquery plugin for that, i presume, something like: https://github.com/blueimp/jQuery-File-Upload/wiki/Options can do the trick for you, and supports both GET and PUT.
Otherwise it would be a pain in the ass to get it to work, but not impossible, since you can access PUT in meteor.
If you would prefer a more pure JS sollution maybe you can look at: http://igstan.ro/posts/2009-01-11-ajax-file-upload-with-pure-javascript.html
And adapt it.
There is no ready made support for file uploads so share what you come up with, i would be very interested!
Alternatively (if you wouldn't like to use a 3rd party solution like filepicker) you could use the meteor router package.
This handles the HTTP requests on server-side.
The website of my university unfortunately does not provide feeds but they keep publishing information there that is important for me (deadlines, dates of exams etc.) as links to pdfs
in a certain section of the website.
How can I regularly scrape that section of the site and have me notified (growl, mail something alike).
Normally I would use wget to mirror it but how to extract only parts of the website?
Is there a cli tool that can extract the XHTML via XPATH or similar?
Try this:
wget --spider --server-response http://example.com
This will print the headers which might contain the "Length"-attribute. If it changes, you can notify yourself.
edit: If it changes, you can download the whole html file, grep for a pdf file or whatever you want to look for (maybe for "<div id='news'>(.*?)</div>")
Mmm... You should take a look at QueryPath. QueryPath makes easy to parse HTML. What if the HTML structure changes? What if you want specific elements of the page? QueryPath does the hard work for you. Do you like JQuery? QueryPath is like the JQuery of PHP.
See: http://www.ibm.com/developerworks/opensource/library/os-php-querypath/index.html?S_TACT=105AGX01&S_CMP=HP
See: http://querypath.org/
You might be interested in looking at Pjscrape (disclaimer: this is my project). It's a web-scraping tool built on PhantomJS, giving you full jQuery access to the page in a headless Webkit browser context. It makes it very easy to pull semi-structured data from webpages via the command line, particularly if the page you're scraping has a consistent structure for new elements.
For example, you can pull all the course titles from this course catalog with the following code:
pjs.addScraper(
// the page you're scraping
'http://www.ischool.berkeley.edu/courses/catalog',
// selector for elements you want to pull text from
'.views-row .views-field-title'
);
// suppress STDOUT logging
pjs.config('log', 'none');
Running this from the command line gives you JSON to STDOUT by default:
~> phantomjs /path/to/pjscrape.js my_script.js
["W10. Introduction to Information","24. Freshman Seminar", ...]
So it would be pretty simple to run this script on a regular basis, capture the output in a file, and then alert you when the new output doesn't match the previous scrape. You can also write your own scraper functions, so there's a lot of flexibility for more complex scraping if a simple selector won't do the trick.
I am writing a set of tests to perform equivalency of web pages. The only differences (declaratively in the test) are the URLs. I'd like to do this by somehow performing multiple store text commands prior to a test so that I can use the stored properties later within the testpage. Is there a clean way to do this?
old properties file
login.page=Login.jsp
new properties file
login.page=/new/Login
And the tests looks like:
.. do some storetexts ..
open | /mypagehome/${login.page}
Sorry to clarify: I have 2 selenium tests for each page. These two tests are exactly the same with the exception of the url. One test the old site , one test the new one. Id like to only have one test and be able to point it to different instances of the site, i cant just use the 'base url' because the urls for both sites are significantly different. How do i get round this problem?
Ok, I think I understand now! :-)
Selenium lets you open absolute URLs instead of just URLs that are relative to the base URL, so you could use something like this:
open | http://somedomain/mypage/${loginpage}
Once I have my renamed files I need to add them to my project's wiki page. This is a fairly repetitive manual task, so I guess I could script it but I don't know where to start.
The process is:
Got to appropriate page on the wiki
for each team member (DeveloperA, DeveloperB, DeveloperC)
{
for each of two files ('*_current.jpg', '*_lastweek.jpg')
{
Select 'Attach' link on page
Select the 'manage' link next to the file to be updated
Click 'Browse' button
Browse to the relevant file (which has the same name as the previous version)
Click 'Upload file' button
}
}
Not necessarily looking for the full solution as I'd like to give it a go myself.
Where to begin? What language could I use to do this and how difficult would it be?
Check if the wiki you mean to talk to supports XMLRPC, because if it does it should be a snap. I wrote a tool called WikiUp to solve a similar problem (updating a delineated section on a wiki page).
If you're writing in C#, the WebClient classes might be a good place to start. I bet people could give more specific advice if you mentioned which wiki platform you are using, and whether it requires authentication, though.
I'd probably start by downloading fiddler and watching the http requests from doing it manually. Then you could use some simple scripts and regexes to build your http requests for automating the process.
Of course, if your wildly lucky, your wiki would have a backend simple enough that you could just plug them into its db directly. :)
You might find CoScripter useful -- it's a Firefox extension that allows you to automate tasks you perform on websites. I'm not certain how you'd integrate this with the list of files you're changing on your local system, but it can certainly handle the file uploading through a web form.
Better bet is probably using cURL or a similar HTTP library with your programming language of choice. If you're on *nix, you can use the cURL commandline program inside your shell script to get this done fairly easily. (Like #jsight said you will need to analyze the actual forms you're using on the webpage, using Fiddler or just looking at the form elements and re-creating the POST through cURL.)