select file in Safari in Protractor - angularjs

Executing this code in Safari doesn't work, but it works in chrome and firefox:
var pathToFile = path.resolve('./scripts', file);
element( by.css('input[ng-file-select="onFileSelect($files)"]')).sendKeys(pathToFile);
In digging around it looks like it's not possible to interact with file inputs in this way in Protractor running on Safari. Does anyone know of a workaround in Safari to put a file path in an input?

This is due to a leaky abstraction, which requires a Safari specific solution:
I guess the workaround for those that really want to do file upload for SafariDriver would be not to do it natively via SafariDriver but by using external code libraries to perform the upload via HTTP/HTTPS (POST) requests (combining any other form data in addition to the file being uploaded/sent), then get response and check whether upload succeeded or not, then go back to SafariDriver code and navigate to next page to check upload succeeded or not, and/or to continue from there for the next steps in the automation.
This approach would be similar to the file download method using HTTP requests externally that has been mentioned in various posts in WebDriver and Selenium user Google groups. Here, it's just the inverse, doing upload instead of download.
Though if the upload requires a session (cookie), then you can extract Selenium session cookie and use with HTTP request. Or if session is stored with session ID in URL, extract that and pass along with HTTP request.
References
Selenium Issue 4220: The SafariDriver does not support file uploads
How to upload file using Selenium when the file input is hidden?
Access is denied error in IE while file uploading
Changing the value of input file
Chrome file upload bug: on change event won't be executed twice with the same file
Selenium IDE 1.4.1 throwing security error when uploading a local file
Dynamically submitting a file upload form in IE10 using jQuery

Related

File upload in Moodle using jmeter

I'm busy setting up a load test for file upload in moodle and I am struggling with the file upload. It seems to be losing the sesskey when it gets to the uploading of the file.
Here is the error message from the response data:
"{"error":"A required parameter (sesskey) was missing","errorcode":"missingparam","stacktrace":null,"debuginfo":null,"reproductionlink":null}".
Please help, this test needs to be done in the next 2 days.
Thank you in advance.
I extracted the sesskey using the Regular Expression Extractor and this worked for downloading a file and taking a quiz in moodle but for file upload it loses the session.
Just record the file upload event using HTTP(S) Test Script Recorder, the only thing you will need to do is to copy the file(s) you will be uploading to "bin" folder of your JMeter installation prior to starting the file upload in the browser, this way JMeter will be able to properly capture the request and generate the relevant HTTP Request sampler and HTTP Header Manager
See Recording File Uploads with JMeter article for more details.
Once you have recorded "skeleton" you can correlate the dynamic values like sesskey

Start a browser with a logged proxy in Robot framework

i'm facing the current problem: Since i'm under VPN, when i open a browser, a browser popup appears and ask me for the user and password credentials:
I need to open a browser in robot framework (firefox or chrome is the same) with a logged proxy.
I know that is possible to open a firefox instance with a proxy by using SeleniumLibrary Create Webdriver:
${proxy}= Evaluate selenium.webdriver.Proxy() modules=selenium, selenium.webdriver
${proxy.http_proxy}= Set Variable localhost:8888
Create Webdriver Firefox proxy=${proxy}
The problem is that it seems not possible to pass the credentials (user and password) for the proxy login.
Also, like most of the people suggest, i know that is possible to open the browser logged in with the proxy by using the url formatted like (in past i've also used that on different projects):
https://proxy_user:proxy_password#url_to_reach.com
but for some reason it doesn't work, i still have the browser popup asking me the credentials.
I've also tried by using Input Text Into Alert but it doesn't fill the alert fields:
Input Text Into Alert text=username action=LEAVE
I've also thought that maybe it is possible to do by using some preferencies with chrome or a profile with firefox but i've found nothing about this. Any other method by javascript?
Anyone can help? Thanks a lot

How to upload file in Front End using Jmeter?

I am trying to upload a file using jmeter on the front end. There are three files that are need to be uploaded and then the Submit button will be enabled. Is there any way to it through jmeter?
I am able to do it from the back end. But i want to use the URL of the website through Jmeter in order to do performance testing of the website.
As per very main page of the Apache JMeter project:
JMeter is not a browser.
As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever viewed at a time).
So JMeter won't check the status of the "Submit" button, it acts on protocol level and will send the corresponding request in any case.
In regards to the File Upload bit itself. You can do it with HTTP Request sampler, just make sure:
You use POST (in some cases it can be PUT) method
Use multipart/form-data for POST box is checked
In Files Upload section the following values are provided:
File Path (either absolute or relative to JMeter's "bin" folder)
Parameter Name (form name which contains <input type="file" ... tag, you can figure that out from upload page source code)
File MIME Type
Actually the easiest way to build a file upload request is just recording it, see Recording File Uploads with JMeter guide for more details.
Steps to perform:
Add HTTP Request in TestPlan
Select the post/put method
Type in the PATH
Select use multipart/form-data
Under the File Upload tab, enter the file path, Parameter Name, and MimeType.
MIME Type examples: image/jpeg, image/png, text/plain
Save and run the test.
Screenshot below:

Can I use "--allow-file-access-from-files" when starting chrome app?

I am trying to load a simple .txt file content with a Chrome App (using file: protocol); I need to show its content for the user in a <div>. I need to open the file from a path typed in a input text (or defined in a string variable).
The flag --allow-file-access-from-files works fine when I load my .txt file content through Chrome browser. However, when I try to do the same with my Chrome App launcher (I have applied --allow-file-access-from-files flag on it), it keeps telling
Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
I dont know if I am missing something or if it is impossible for chrome app.
My user will work with the app in Windows platform.
I finally figured out that --allow-file-access-from-files does not work at all in my case.
I started coding using fileSystem and made something like the recomended in this question, following the main example. Now I am able to work with files in a directory asking the user to choose it only one time.

Getting following message when opening a pdf "Internet cannot download ......xyz from abc.com The file could not be written in the cache" in IE?

Our Application is build on Spring framework and it is hosted on WAS 6.1. It was designed for the Internet Explorer 6 (as the users using IE 6). It is opening a pdf file through AJAX communication through the controller. In the background it calls a mq to fetch the byte[]. It is written in the bufferedOutputStream of the response.
It is working fine in development and testing environment but in production environment it is not working fine always. It is opening sometimes, sometimes it is not. (For load balancing we have more than 1 servers.)
Sometimes the request query string is set in the filename and while trying to save the attachment it is giving the following error message in the pop up:
"Internet cannot download ......url from abc.com The file could not be written in the cache"
PFB the code:
byte[] letterByteArr = null;
letterByteArr = fetchFromMQ();
bufferedOutputStream = new BufferedOutputStream(response.getOutputStream());
response.reset();
response.setContentType(application/pdf);
response.setHeader(Content-disposition, attachment; filename=LP.pdf);
int length = letterByteArr.length;
response.setContentLength(length);
bufferedOutputStream.write(letterByteArr, 0, length);
bufferedOutputStream.flush();
The similar piece of code is running fine in another application which is running in different jvm.
Could anyone suggest the possible solutions for this problem if they faced during your code implementation? Where could be the possible problem in WAS, network, IE or Abode?
This sounds much like http://support.microsoft.com/kb/812935. The problem is, IE6 won't download the PDF file when it is served over HTTPS instead of HTTP while the Cache-Control and/or Pragma headers are set to no-cache.
Add the following response headers:
response.setHeader("Cache-Control", "public");
response.setHeader("Pragma", "public");
I am facing the same problem and I added the reponse headers to solve this problem.
But I had to remove the response.reset(); ; only after that the downloading problem is not occuring.
I don't know the reason behind this but it's working.
The issue only is that the data of the excel is different to the data in pdf fiel in my application.

Resources