Skip to content

Instantly share code, notes, and snippets.

View PramodKumarYadav's full-sized avatar

Pramod Kumar Yadav PramodKumarYadav

View GitHub Profile
package org.powertester.hulk.actions.session;
import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.html5.Location;
public class GeoLocation {
AppiumDriver driver;
public GeoLocation(AppiumDriver driver) {
this.driver = driver;
PS C:\Program Files\PowerShell\7> appium --base-path /wd/hub
[Appium] Welcome to Appium v2.0.0-beta.18
[Appium] Non-default server args:
[Appium] basePath: /wd/hub
[Appium] tmpDir: C:\Users\PRAMOD~1\AppData\Local\Temp
[Appium] Attempting to load driver uiautomator2...
[Appium] Attempting to load driver xcuitest...
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[Appium] Available drivers:
[Appium] - uiautomator2@1.71.0 (automationName 'UiAutomator2')
@PramodKumarYadav
PramodKumarYadav / TestConfig
Created February 13, 2021 19:38
A solution to load config properties based on a chosen test environment
package org.powertester.testconfig;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@Slf4j
public class TestConfig {
public static Config getConfig() {
@PramodKumarYadav
PramodKumarYadav / DBConnection
Last active December 11, 2021 15:16
A DBConnection class to connect to any database
package org.powertester.yourprojectname.database;
import com.typesafe.config.Config;
import lombok.extern.slf4j.Slf4j;
import org.powertester.yourprojectname.config.TestEnvironment;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
@PramodKumarYadav
PramodKumarYadav / DriverFactory
Last active December 16, 2020 14:24
Create webdriver
// Details on how to run test scripts with different browsers from maven command line (and thus from CI)
// https://seleniumjava.com/2017/05/21/how-to-run-scripts-in-a-specific-browser-with-maven/amp/
// Driver should work with whatever browser passed to them (either via CI, CMD line or in rare cases - from tests(not recommended way)
// Thus browser is abstracted outside driver class.
// Driver constructor makes sure that it can work with both cases (both with default browser or when browser is passed to it)
package org.epo.apollo.webdriver;
import com.typesafe.config.Config;
import io.github.bonigarcia.wdm.WebDriverManager;
@PramodKumarYadav
PramodKumarYadav / Jenkinsfile
Last active December 13, 2020 20:19
A sample Jenkins file to parse mvn results
String cron_string = BRANCH_NAME == "fix/pipeline-trigger" ? "@hourly" : ""
pipeline{
agent any
environment {
HOST = 'myproject.develop'
REMOTE = 'false'
HEADLESS = 'true'
BROWSER = 'chrome'
TEST = 'TestAddressBook*'
@PramodKumarYadav
PramodKumarYadav / test-result.sh
Last active December 13, 2020 20:07
mvn result parser
#!/bin/sh
# https://devops.stackexchange.com/questions/6085/how-can-we-get-the-jenkins-console-output-in-a-text-file
# https://unix.stackexchange.com/questions/264962/print-lines-of-a-file-between-two-matching-patterns
# https://issues.jenkins.io/browse/JENKINS-61263
echo "Getting test results log from: $1"
cd ci
curl -q $1 > run-log.txt
echo "Get text between Result and maven-surefire report-plugin sysout"
@PramodKumarYadav
PramodKumarYadav / Balanced Rows.EXCEL.yaml
Last active March 27, 2020 21:55
A balanced view (with best of both Collapsed rows and Expand Rows views)
name: Balanced Rows
description: A balanced view (with best of both Collapsed rows and Expand Rows views)
host: EXCEL
api_set: {}
script:
content: |
$("#balanced-rows").click(() => tryCatch(balancedRows));
async function balancedRows() {
await Excel.run(async (context) => {
@PramodKumarYadav
PramodKumarYadav / Reading views.EXCEL.yaml
Last active April 2, 2020 15:54
Three different reading views for reading excel sheets.
name: Reading views
description: Three different reading views for reading excel sheets.
host: EXCEL
api_set: {}
script:
content: |
$("#balanced-rows").click(() => tryCatch(balancedRows));
$("#collapse-rows").click(() => tryCatch(collapseRows));
$("#expand-rows").click(() => tryCatch(expandRows));
@PramodKumarYadav
PramodKumarYadav / Collapse Rows.EXCEL.yaml
Last active March 27, 2020 14:44
This add in collapses all rows to give you a high level reading view.
name: Collapse Rows
description: This add in collapses all rows to give you a high level reading view.
host: EXCEL
api_set: {}
script:
content: |
$("#collapseRows").click(() => tryCatch(run));
async function run() {
await Excel.run(async (context) => {