Skip to content

Instantly share code, notes, and snippets.

View pragmatictesters's full-sized avatar
😀
Learn | Train | Earn

Janesh Kodikara pragmatictesters

😀
Learn | Train | Earn
View GitHub Profile
@pragmatictesters
pragmatictesters / JMeter-WebDriverSampler.js
Last active January 10, 2023 10:40
JMeter WebDriver Sampler : Useful commands
//Working with the browser
//Please refer to Selenium WebDriver API for available methods
//https://www.selenium.dev/selenium/docs/api/java/index.html?overview-summary.html
//1.1 Navigate to a URL
WDS.browser.get("https://jmeter-plugins.org")
//1.2 Get the page Title
WDS.browser.getTitle()
@pragmatictesters
pragmatictesters / JMeter-WebDriver-SavingRecords.js
Created January 2, 2023 07:28
JMeter Example : WebDriver Sampler - Saving a record
var pkg = JavaImporter(org.openqa.selenium)
var time = JavaImporter(java.time)
var support_ui = JavaImporter(org.openqa.selenium.support.ui);
var wait = new support_ui.WebDriverWait(WDS.browser, time.Duration.ofSeconds(30));
WDS.sampleResult.sampleStart();
WDS.browser.findElement(pkg.By.cssSelector('#IncidentObject_Save')).click()
waitUntilLoadingIsCompleted();
@pragmatictesters
pragmatictesters / JMeter-WebDriver-Sampler-Access-Page.js
Created January 2, 2023 07:21
JMeter Example : WebDriver Sampler access a page in the system
var pkg = JavaImporter(org.openqa.selenium)
var time = JavaImporter(java.time)
var support_ui = JavaImporter(org.openqa.selenium.support.ui);
var wait = new support_ui.WebDriverWait(WDS.browser, time.Duration.ofSeconds(30));
WDS.sampleResult.sampleStart();
WDS.log.info("Start navigating to new bus incident creation page");
waitAndClick(pkg.By.cssSelector("#New"));
waitAndClick(pkg.By.cssSelector("#BusIncident_3"));
@pragmatictesters
pragmatictesters / JMeter-WebDriver-Sampler-Access-Login-Script.js
Last active January 2, 2023 07:19
JMeter Examples : WebDriver Sampler Script for getting page load time of login page
WDS.browser.manage().window().maximize()
WDS.sampleResult.sampleStart();
WDS.log.info("Login page loading is started");
WDS.browser.get("${base_url}")
WDS.log.info("Login page is loaded");
WDS.sampleResult.sampleEnd();
@pragmatictesters
pragmatictesters / SauceLogin.feature
Created July 9, 2022 04:33
Sample feature file
Feature: Login feature
Scenario: Login as a standard user
Given User has accessed the login page "https://www.saucedemo.com"
When User type username "standard_user"
And User type password "secret_sauce"
And User click the login button
Then User should be directed to inventory page "https://www.saucedemo.com/inventory.html"
@pragmatictesters
pragmatictesters / azure-pipelines-testcafe.yml
Last active July 14, 2022 07:17
TestCafe Azure DevOps Integration : Sample YAML pipeline with videos and screens publishes as artefacts
jobs:
- job: Smoke_Staging_Tests
displayName: Smoke tests on staging environment
continueOnError: true
pool:
vmImage: "windows-2022"
timeoutInMinutes: 180
steps:
- script: npm install
displayName: "Install TestCafe and other dependencies"
@pragmatictesters
pragmatictesters / MailosaurExample.java
Created May 28, 2022 08:18
Selenium integration with Mailosaur for reading emails
package com.pragmatic.email;
import com.mailosaur.MailosaurClient;
import com.mailosaur.MailosaurException;
import com.mailosaur.models.Link;
import com.mailosaur.models.Message;
import com.mailosaur.models.SearchCriteria;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
@pragmatictesters
pragmatictesters / HelloSelenium.java
Created May 26, 2022 07:54
Selenium Training - Sample code to verify the environment
package com.pragmatic.selenium;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class HelloSelenium {
@pragmatictesters
pragmatictesters / pom.xml
Created May 26, 2022 07:50
Selenium Training - Sample pom.xml with initial dependencies
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pragmatic</groupId>
<artifactId>selenium</artifactId>
<version>1.0-SNAPSHOT</version>
@pragmatictesters
pragmatictesters / remove-ramping-test-results.groovy
Created August 24, 2021 11:51
Remove the rampup and rampdown test results from test result file
File file = new File("runLoadTest.jtl")
def line, noOfLines=0;
def starTime
def addedLines=0
file.withReader {it->
line= it.readLine()
line= it.readLine()
starTime = line.split(",").first().toLong()