Skip to main content

Posts

Showing posts from December, 2016

File upload and WebDriver (Where is my File?)

You may have come across file upload use case when working with WebDriver. File upload is quite easy since it is same as typing in a text box but herein we need to pass path of file to be uploaded. I used to keep a static file in src/test/resources folder of maven project and would use it for upload operation. But you can also generate file during run time using java.nio.file.Files class. Files class has createTempFile(java.lang. String, java.lang.String, java.nio.file.attribute. FileAttribute...) method which can be used to generate temporary files. For ex, you can generate a temporary pdf file and get back the File object as following - File file = Files. createTempFile ( "test-" + accountNumber, ".pdf" ).toFile(); generatePDF (file, StringUtils. repeat ( "Dummy PDF" , 10 )); And this is how generatePDF looks - public static File generatePDF(File file, String content) { try { Document e = new Document();

Recording curl request with JMeter Recorder

Just use https://jmeter.apache.org/usermanual/curl.html and no JMeter proxy etc needed : )   Though it is quite east to convert curl requests to corresponding JMeter request. At times you might be stuck with issue like I faced when uploading a file with  JMeter HTTP request In a gist I kept getting 404 error when using REStful service to upload a file. After days of investigations I found it that I should be using HTTP request implementation java and not HttpClient4. JMeter HTTPs Test Script recorder was of great help to debug this issue. This post describes the process of recording curl request through JMeter HTTPs Test Script recorder. If you have never used JMeter HTTPs Test Script recorder then create a new JMeter Plan and under WorkBench > Add > Non Test Element > HTTP(s) Test Script Recorder.  Specify Global Setting > Port as 8090 If we were using browser to record web application then we would configure its proxy to 127.0.0.1 (Since http proxy server