Skip to content

Instantly share code, notes, and snippets.

View sahajamit's full-sized avatar

Amit Rawat sahajamit

View GitHub Profile
@sahajamit
sahajamit / CSSandXpaths.txt
Created July 27, 2016 08:21
tips and tricks for css and xpath for selenium locators
$x("<xpath>")
command that will look for files with an extension “c”, and has the occurrence of the string “apple” in it.
Find ./ -name “*.c” | xargs grep –i “apple”
To find a file:
find . -name "foo*"
*************************************************************************
rm -rf lampp (remove recursively and forcefully)
unmae -a
zip -r myfiles.zip myfiles
@sahajamit
sahajamit / build.xml
Created August 18, 2016 06:00
Ant Build xml to run testng xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- WARNING: Eclipse auto-generated file.
Any modifications will be overwritten.
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?eclipse.ant.import?>
as the first entry and export the buildfile again. -->
<project name="Automation" default="run" basedir=".">
<!-- ________________________initialize properties____________________________ -->
<property environment="env"/>
<property name="ws.home" value="."/>
@And("^we login to the UI with correct credentials$")
public void weLoginToTheRiskViewUIWithCorrect() throws Throwable {
homePage = loginPage.doLogin(context.get("USER").toString(), context.get("PASSWORD").toString(), false);
}
@And("^we login to the UI with incorrect credentials$")
public void weLoginToTheRiskViewUIWithIncorrectCredentials() throws Throwable {
loginPage = loginPage.doLogin(context.get("USER").toString(), context.get("INCORRECT_PASSWORD").toString(), true);
}
http://stackoverflow.com/questions/16333790/node-js-quick-file-server-static-files-over-http
npm install http-server -g
http-server D:\Folder
@sahajamit
sahajamit / testngListOfMaps_DataProvider.java
Created August 8, 2017 05:57
TestNG dataprovider example to pass List of maps as a provider
package testng;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.util.*;
public class testngListOfMaps_DataProvider {
@DataProvider(name = "Passing List Of Maps")
public Iterator<Object[]> createDataforTest3() {
@sahajamit
sahajamit / StaleElementUtils.java
Last active July 18, 2018 15:03
Code to refresh a stale web element
package com.sahajamit.selenium.utils;
import com.sahajamit.selenium.driver.DriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException;
@sahajamit
sahajamit / npm commands
Created August 17, 2017 03:41
npm commands
npm view <package> version - returns the latest available version on the package.
npm list --depth=0 - returns versions of all installed modules without dependencies.
npm list - returns versions of all modules and dependencies.
npm list -g - returns versions of all modules and dependencies globally
node -v
npm info YOUR_PACKAGE version
const makeRequest = () => {
try {
getJSON()
.then(result => {
// this parse may fail
const data = JSON.parse(result)
console.log(data)
})
// uncomment this block to handle asynchronous errors
// .catch((err) => {
const makeRequest = async () => {
try {
// this parse may fail
const data = JSON.parse(await getJSON())
console.log(data)
} catch (err) {
console.log(err)
}
}