This question already has answers here:
API Automation Testing : Is there any way to automate download scenario with content validation?
(2 answers)
Closed 1 year ago.
When PDF hyperlinks selected using karate chromedriver, the files are opening in new tab rather than downloaded to the local system. I tried with below ChromeOptions while configuring the driver, but none of them looks worked for me.
karate.configure('driver;, {type:'chromedriver', executable: path, webDriverSession:{desiredCapabilities:{browserName:'chrome', "goog:chromeOptions":{"prefs": {"pdfjs.disabled": true}}}}});
Below preferences also did not work.
"prefs": {"plugins.always_open_pdf_externally": true,"plugins.plugins_disabled", "Chrome PDF Viewer"}
I went through karate docs but couldn't find a similar topic. I really appreciate if anyone can help me with this issue or guide me to the documentation.
Downloading files via WebDriver happens to be listed among their worst practices. The recommendation is to just get the URI from the DOM and use whatever http client you have available.
Thanks Peter & Matthias for the idea. I am able to download the file after updating the element DOM structure using JavaScript.
var lnkName = element.attribute['href'];
script("document.getElelmentById('pageLinks').setAttribute('download','"+lnkName+"');");
element.click();
I strongly suggest that in this case you just get the hyperlink of the PDF and use the Karate API testing functionality to download the file anywhere you want. You can find tips here: How to get the downloaded xlsx file from the api endpoint in karate? - and also look at the "upload.feature" example in the Karate demos.
If you need to execute some JS to get the final URL of the file, that is quite possible: https://stackoverflow.com/a/60800181/143475
Otherwise you need to continue doing some research, I don't know the answer and hopefully you can contribute your findings back.
Related
My question relates to implementing the solution proposed in this post. The error I first get is that the webdriver is not defined. For that, I tried the following solution. But at that point, I get an error that "require()" is not defined, which brought me to this final solution. I tried the recommended Browserify option, but I don't think it's going to work for me because I can't just throw a "script src="bundle.js"" into the html as I want to use the webdriver to open the YouTube "stats for nerds" menu every time an ad is detected to get the video ID of that ad via a Chrome extension. Not sure if this is possible. Any help would be highly appreciated. I'm new to JS.
This question already has answers here:
Handling Basic Authentication in Karate UI scenario
(2 answers)
Closed 1 year ago.
I need to allow the geo location during my karate web automation test.
I was going through this documentation https://github.com/intuit/karate/tree/master/karate-core
It has information on handling dialog boxes and popup but they don't seem to be working for the geo location pop up
Thanks to the comment above, looks like for Chrome you can use the addOptions to pass disable-geolocation:
* configure driver = { type: 'chrome', addOptions: [`disable-geolocation`] }
I guess it would be similar for other browsers. If needed please consider submitting a PR to the project.
Also note that we are working on Karate Robot that may be able to solve this in the future.
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
this is not a question but kind of a request.
I have tried to find right place to post
(asked to msdn forum, partnership support, ...)
but failed.
why microsoft gives me this difficulty?
can't place a total official support page?
anyway, this is not the subject of this post.
someone suggested me to post here.
(https : // social.msdn.microsoft.com/Forums/en-US/11fd7f37-bec6-4201-b5ce-085f24446362/forum-for-office-365-filehandler-addin?forum=whatforum)
I asked this question before, and I know it is impossible at current time.
(http : // stackoverflow.com/questions/36172056/can-i-make-office-365-file-handler-for-existing-file-format-docx-xlsx-pptx)
but I need that feature. (open docx file with custom file handler)
so I want to request microsoft to support this feature.
and want to have clear answer thought it will be "never available."
if replacing associated webapp(office online) is unacceptable,
way to add new context menu item is enough, I think.
(like google drive does - https : // developers.google.com/drive/v3/web/integrate-open)
If you want to file handler to support the Office document, you can submit the feedback from here. And you can find the document/resource/code sample about Office development from the Office Dev Center.
possible with custom action of file handler 2.0
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.)