Skip to content

Instantly share code, notes, and snippets.

View djangofan's full-sized avatar

Jon Austen djangofan

View GitHub Profile
public static void mouseClickByLocator( String cssLocator ) {
String locator = cssLocator;
WebElement el = driver.findElement( By.cssSelector( locator ) );
Actions builder = new Actions(driver);
builder.moveToElement( el ).click( el );
builder.perform();
}
private ExpectedCondition<Boolean> element(final By findCondition) {
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver from) {
RenderedWebElement element = (RenderedWebElement)
driver.findElement(findCondition);
return element.isDisplayed();
}
};
}
@djangofan
djangofan / RWDTest.java
Created November 21, 2012 19:24 — forked from testingbot/gist:2428497
Selenium-2 Remote WebDriver Example
//use testingbot.com or saucelabs or roll your own remote webdriver server
import junit.framework.TestCase; //removes need for annotations by extending
import org.openqa.selenium.*;
import org.openqa.selenium.remote.*;
import java.net.URL;
import java.util.concurrent.TimeUnit;
public class RWDTest extends TestCase {
private WebDriver driver;
@djangofan
djangofan / CollectionFilter.xtend
Created August 7, 2012 19:49 — forked from quicy/CollectionFilter.xtend
Collection filter by Xtend closure
import java.util.List
import static extension java.util.Collections.*
class CollectionFilter {
def static void main(String[] _) {
val values = new ArrayList( 1, 5, 33, 0, -2, -10, 4, 36, -82 )
positiveOnly( values )
negativeOnly( values )
@djangofan
djangofan / wd.java
Created March 13, 2012 21:43 — forked from jarib/wd.rb
selenium-webdriver wait
public WebElement waitFindElement(WebDriver drv, By by, long timeout, long interval)
{
long start = System.currentTimeMillis();
while(true){
try{
return drv.findElement(by);
} catch(NoSuchElementException nse) {
if(System.currentTimeMillis()-start>=timeout)
{
throw new Error("Timeout reached and element["+by+"]not found");