Skip to content

Instantly share code, notes, and snippets.

View sayems's full-sized avatar

Syed Sayem sayems

View GitHub Profile
@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 / 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> {
@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;
from selenium import webdriver
from selenium.webdriver.common.by import By
class Page(object):
"""
Base class that all page models can inherit from
"""
def __init__(self, selenium_driver, base_url='https://test.axial.net', parent=None):
self.base_url = base_url
# To install the Python client library:
# pip install -U selenium
# Import the Selenium 2 namespace (aka "webdriver")
from selenium import webdriver
# iPhone
driver = webdriver.Remote(browser_name="iphone", command_executor='http://172.24.101.36:3001/hub')
# Android
# When Mac OS X Mountain Lion was released, I did a completely clean install. Unfortunately [RVM](http://rvm.io) won't install directly on the stock release. Here are the steps to get the installation working.
# This gist is based in part by [this post](http://theengguy.blogspot.ca/2012/04/setting-up-os-x-lion-and-mountain-lion.html) by [@theengguy](http://twitter.com/theengguy).
# 1. Install [MacPorts](http://www.macports.org)
# You can snag the package installer (easiest) from [https://distfiles.macports.org/MacPorts/MacPorts-2.1.2-10.8-MountainLion.pkg](https://distfiles.macports.org/MacPorts/MacPorts-2.1.2-10.8-MountainLion.pkg)
# 2. Install a new version of curl
sudo port -v selfupdate
sudo port install curl
var script = "some javascript";
var js = driver as IJavaScriptExecutor;
var isDataCorrect = js.ExecuteScript(script);
Assert.True(isDataCorrect);
@sayems
sayems / gist:3318863
Created August 10, 2012 23:07 — forked from djangofan/LoadableComponentExample.java
Using Java Selenium Webdriver and LoadableComponent to handle page changes
public class ExpectedPage extends SlowLoadableComponent<ExpectedPage> {
private WebDriver driver;
private String pagelabel;
private static int timeOutInSeconds = 3; // this controls how long get() method will
// delay after load() and before isLoaded()
public ExpectedPage(WebDriver drv) {
super(new SystemClock(), timeOutInSeconds);
System.out.println("Loading ExpectedPage Page");
this.driver = drv;