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

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

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.

Related

Why im not able to use executeScript in my selenium script?

import org.openqa.selenium.*;
import org.openqa.selenium.JavascriptExecutor.executeScript;
You don't need executeScript in your import:
import org.openqa.selenium.JavascriptExecutor;

Unable to run selenium webdriver scripts even after all the jars installed

I am unable to run selenium webdriver scripts on pc. I have all the necessary jar files and java installed on my pc but still I am getting just too many errors.I have attached the build path and errors in links below.
Here is the code:-
package Webdriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class firstscript {
public static void main(String args[]) {
System.setProperty("webdriver.chrome.driver","C:\\Users\\gkuma218\\Downloads");
WebDriver driver=new ChromeDriver();
String baseurl="https://stage-portal.uhcglobal.com/testMyUHC/generate-open-token.html";
driver.get(baseurl);
driver.findElement(By.id("txteeid")).sendKeys("00000907777");
driver.findElement(By.id("txtdob")).sendKeys("19920828");
driver.findElement(By.id("txtfirstname")).sendKeys("Sanette");
driver.findElement(By.id("txtlastname")).sendKeys("ABATE");
driver.findElement(By.id("txtgroupid")).sendKeys("0742631");
driver.findElement(By.id("btnSubmit")).click();
}
}
Here are the errors:-
https://i.stack.imgur.com/m2euR.png
Here is the build path:-
https://i.stack.imgur.com/l5692.png
Possibly a classic case of Cyclic redundancy.
Solution:
Either you rename the project name as seleniumTests and module name as webdriverTests
Or you may like to create a new project with a unique name excluding the keywords selenium and webdriver.

Click button doesn't work - Katalon Studio

I am new to Katalon studio and am trying to run my test case but it's always filed as it says:
Error:
Test Cases/Logging in FAILED because (of) (Stack trace: com.kms.katalon.core.exception.StepFailedException: Unable to >click on object 'Object Repository/Page_BaseLine - test/input_Przypomnienie o fakturze' (Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: 'Object Repository/Page_BaseLine - test/input_Przypomnienie o fakturze' located by 'By.xpath: >//input[#id='SubmitButton']' not found)
I tried to do it manually but everytime the same problem appears, what shall I do then?
Here is my source code:
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testcase.TestCaseFactory as TestCaseFactory
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
WebUI.openBrowser('')
def plik = new File('Config.txt')
def lines = plik.readLines()
WebUI.navigateToUrl(lines[0])
WebUI.setText(findTestObject('Object Repository/Page_Demo version BaseLine/input_Login form_LoginTextBox'), lines[1])
WebUI.setText(findTestObject('Object Repository/Page_Demo version BaseLine/input_Login form_PasswordTextB'), lines[2])
WebUI.click(findTestObject('Object Repository/Page_Demo version BaseLine/input_remember me_LoginButton'))
WebUI.click(findTestObject('Page_BaseLine - test/a_Kontrahenci'))
WebUI.click(findTestObject('Page_BaseLine - test/a_Dodaj Kontrahenta'))
WebUI.setText(findTestObject('own/Page_BaseLine - test/input_Nazwa skrcona_ShortNameT'), 'greg12')
WebUI.setText(findTestObject('own/Page_BaseLine - test/textarea_'), 'Grzegorz Spytek12')
WebUI.click(findTestObject('Page_BaseLine - test/input_Przypomnienie o fakturze'))
WebUI.click(findTestObject('Page_BaseLine - test/input_Opis_CloseButton'))
Thanks for help.
The xpath seems not correct. Could you try removing the '>'?
>//input[#id='SubmitButton']'

Selenium remote WebDriver issue

I am trying to do parallel execution using Selenium in my machine. I have configured hub and node successfully. But in my code, I am getting an error at remote web driver initialization.
My code:
package com.selenium.gautham;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
public class test {
#Test
public static void sample()
{
DesiredCapabilities cap =DesiredCapabilities.internetExplorer();
cap.setBrowserName("ie");
cap.setPlatform(Platform.WINDOWS);
RemoteWebDriver driver =RemoteWebDriver(new URL("http://localhost:4444/wb/hub"),cap);
driver.get(url);
}}
I'm getting this error:
The constructor RemoteWebDriver(URL, DesiredCapabilities) is undefined
Where did I do wrong?
Screenshot of Code
In your imports (before the start of the class), i haven't seen an import for the URL Class. I believe you are trying to use the below constructor of RemoteWebDriver Class.
RemoteWebDriver(java.net.URL remoteAddress, Capabilities desiredCapabilities)
If so, i would suggest you to first try replacing the below line
RemoteWebDriver driver =RemoteWebDriver(new URL("http://localhost:4444/wb/hub"),cap);
to the one below and see if its working fine.
RemoteWebDriver driver = RemoteWebDriver(java.net.URL("http://localhost:4444/wb/hub"), cap);
If you see the above alternative working then import
java.net.URL

Can't access sub menu using webdriver

Can't access submenu eventhough i was able to hover over the parent menu and this is happening only for the site:
upon login need to access Candidates under Recruitment
http://www.livetech.co.in/hrms/symfony/web/index.php/auth/login
code:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.Alert;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import static org.testng.Assert.assertTrue;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.testng.annotations.*;
public class Mouseover {
public static void main(String[] args) throws Exception
{
WebDriver driver= new FirefoxDriver();
driver.navigate().to("http://www.livetech.co.in/hrms/symfony/web/index.php /auth/login");
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.name("txtUsername")).sendKeys("selenium");
driver.findElement(By.name("txtPassword")).sendKeys("selenium");
driver.findElement(By.name("Submit")).click();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
Actions action=new Actions(driver);
action.moveToElement(driver.findElement(By.xpath("//a[#id='menu_recruitment_viewRecruitmentModule']/b"))).click();
//driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Thread.sleep(10000);
driver.findElement(By.xpath("//div[#id='wrapper']/div[2]/ul/li[5]/ul/li/a")).click();
System.out.println("executed");
}
}
can anyone help.
Regards,
Ram.
First of all you are using incorrect Xpath. Remove . . In your case it should start from //. //*[#id='menu_recruitment_viewRecruitmentModule']/b
Secondly if your motive is to reach to Candidates tab then directly click on Recruitment. It will solve your purpose.
Finally if you want to use mouse hover then you can easily implement it, but I suggest not to do it because you have easy way to do it.
Last call is always your
Thanks