Deepak N
Deepak N

Reputation: 1639

How to run Jmeter webdriver sampler file uploading script in blazemeter?

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----------------");
}

Upvotes: 2

Views: 1618

Answers (1)

Dmitri T
Dmitri T

Reputation: 168052

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.

Upvotes: 1

Related Questions