Skip to content

Instantly share code, notes, and snippets.

View sayems's full-sized avatar

Syed Sayem sayems

View GitHub Profile
public class Rec87 {
private PropertiesUtil factory;
private List<String> listX;
private List<String> listY;
private String userIdX;
private String locationNameX;
private String userNameX;
@sayems
sayems / gist:604024f7ef5f7e9330cc
Created March 14, 2016 20:30 — forked from monperrus/gist:3761429
Table data extraction with Selenium 2
WebDriver webDriver = new FirefoxDriver();
webDriver.navigate().to("http://example.com/some/page");
// simplified: find table which contains the keyword
WebElement tableElement = webDriver.findElement(By.xpath("//table[contains(text(), 'Username')]"));
// create empty table object and iterate through all rows of the found table element
ArrayList<HashMap<String, WebElement>> userTable = new ArrayList<HashMap<String, WebElement>>();
ArrayList<WebElement> rowElements = tableElement.findElements(By.xpath(".//tr"));
@sayems
sayems / DisabledElement.java
Created January 22, 2016 20:58
How To Test For Disabled Elements
driver.get("http://the-internet.herokuapp.com");
driver.findElement(By.linkText("Dropdown")).click();
List<WebElement> dropdown=driver.findElements(By.xpath("//select[@id='dropdown']/option"));
for (int i = 0; i < dropdown.size(); i++) {
if(dropdown.get(i).getText()=="Please select an option")
{
//assert false will always expects false value.
//Here option is disabled so it will return false
Assert.assertFalse(dropdown.get(i).isEnabled());
}
@sayems
sayems / DocumentSettleCondition.java
Created January 8, 2016 03:02 — forked from double16/DocumentSettleCondition.java
Selenium document ready state settled condition
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
/**
* Licensed under MIT License
* Wraps a condition so that it returns only after the document state has settled for a given time, the default being 2 seconds. The
* document is considered settled when the "document.readyState" field stays "complete" and the URL in the browser stops changing.
*/
public class DocumentSettleCondition<T> implements ExpectedCondition<T> {
package com.namely.selectors.id;
import org.openqa.selenium.By;
import java.util.function.Supplier;
import static org.openqa.selenium.By.id;
/**
* Created by sayem on 12/30/15.
@sayems
sayems / ajax.java
Created December 24, 2015 00:41
It checks if the JQuery is active or not and wait till it is active.
Boolean isJqueryUsed = (Boolean)((JavascriptExecutor)driver).executeScript("return (typeof(jQuery) != 'undefined')"));
if(isJqueryUsed){
while (true){
// JavaScript test to verify jQuery is active or not
Boolean ajaxIsComplete = (Boolean)(((JavascriptExecutor)driver).executeScript("return jQuery.active == 0"));
if (ajaxIsComplete) break;
try{
Thread.sleep(100);
}catch (InterruptedException e) {}
}
package com.sayem.browser;
import java.net.URL;
import java.util.Map;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
@sayems
sayems / Builder.java
Last active August 29, 2015 14:15 — forked from qnoid/Builder.java
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.function.Supplier;
import java.util.function.UnaryOperator;
class Person
{
String name;
int age;
import org.apache.jmeter.control.LoopController;
import org.apache.jmeter.engine.StandardJMeterEngine;
import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.TestPlan;
import org.apache.jmeter.threads.SetupThreadGroup;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.collections.HashTree;
public class JMeterTestFromCode {
apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = "com.booker"
version = '1.0'
repositories {