2

I have a Jmeter webdriver sampler script it is running fine in Jmeter. Now I want it to run on blazemeter. Since I was using local directory in Jmeter it was fine. But I am not able to upload file using any path. Can some body help on this. I need to upload file in blazemeter using jmeter webdriver sampler. What path Can I give and where should I keep my file?

Also I tried my file keeping in shared folders of Blazemeter. but I failed in that. Please some body give some syntax for it.

import org.apache.jmeter.services.FileServer;
import org.openqa.selenium;
import java.awt.Robot;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
import org.openqa.selenium.firefox.FirefoxProfile;
import java.time.temporal.ChronoUnit;
import java.time.format.DateTimeFormatter;  
import java.time.LocalDateTime;   
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.FileWriter;
import java.util.concurrent.TimeUnit;
import java.util.ArrayList;
import org.testng.asserts.SoftAssert;
import java.util.List;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
WebDriverWait wait= new WebDriverWait(WDS.browser,20);
WDS.sampleResult.sampleStart();


wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//ul[@class='menu-main']/child::li"))).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//p[@class='btn btn-outline']"))).click();
WDS.log.info("Dialog box");
Robot robot= new Robot();
robot.setAutoDelay(2000); 
filepath="home/jmeter/Deepak/ColumnFunctionFile.csv";
StringSelection stringselection = new StringSelection(filepath);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringselection, null);

robot.setAutoDelay(1000);
WDS.log.info("Copy");
 robot.keyPress(KeyEvent.VK_CONTROL);
      robot.keyPress(KeyEvent.VK_V);
WDS.log.info("release");
      robot.keyRelease(KeyEvent.VK_CONTROL);
      robot.keyRelease(KeyEvent.VK_V);
WDS.log.info("enter press release");
      robot.keyPress(KeyEvent.VK_ENTER);
      robot.keyRelease(KeyEvent.VK_ENTER);
      robot.setAutoDelay(2000);
//upload file status

WebDriverWait wait2= new WebDriverWait(WDS.browser,5);
oldTimeForProgress=LocalDateTime.now();
try{
wait2.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='progress progress-mini']")));
WDS.log.info("--------------------------------Progress bar gets invisible now-------------------");
}
catch(Exception e)
{
WDS.log.info("---------------Looking like file got stuck in processing messages----------------");
}
Deepak N
  • 1,408
  • 3
  • 15
  • 37

1 Answers1

1

As far as I can see from the Selenium Webdriver Based Testing article you should just upload your .jmx script and BlazeMeter will pick it up. Just make sure not to use Internet Explorer as their systems seem to be running on Linux so only Firefox and Chrome are supported.

Also my expectation is that you should reach out to BlazeMeter Support in case of any issues, they should be more aware of their infrastructure than anyone here.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • I am using Chrome, other all tests are running fine but only uploading files to some application is a problem – Deepak N Dec 12 '17 at 13:46
  • Just upload your file along with your script and you can refer it by filename only. If you need the full path - you can go for something like `java.lang.System.getProperty('user.dir') + '/' + 'your_file_name.here'` See [Uploading Files & Shared Folders](https://guide.blazemeter.com/hc/en-us/articles/207420175-Uploading-Files-Shared-Folders) for more details. – Dmitri T Dec 12 '17 at 13:52
  • Please Can you provide a syntax for this as considering filename as trial.txt – Deepak N Dec 12 '17 at 13:56
  • Thanks It helped me – Deepak N Jan 06 '18 at 09:38