Skip to content

Commit

Permalink
Performance improvements: forces WebDriver to force an immediate resp…
Browse files Browse the repository at this point in the history
…onse for findElements() calls if no matching elements are found, and some other minor improvements.

Also improved step logging to include the test class and method as well as the step name.

Signed-off-by: John Ferguson Smart <[email protected]>
  • Loading branch information
wakaleo committed Jan 30, 2015
1 parent f9d9969 commit 068315f
Show file tree
Hide file tree
Showing 22 changed files with 1,238 additions and 246 deletions.
56 changes: 29 additions & 27 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,32 @@ allprojects {
// TODO make work for generated Maven POM...
// it's working for gradle build, but also had to exclude old transitives for generated POM
force 'asm:asm:3.3.1',
'com.fasterxml.jackson.core:jackson-annotations:2.4.3',
'com.google.code.gson:gson:2.3',
'com.google.guava:guava:18.0',
'com.google.inject.extensions:guice-multibindings:3.0',
'com.google.inject.extensions:guice-servlet:3.0',
'com.google.inject:guice:3.0',
'com.thoughtworks.xstream:xstream:1.4.1',
'commons-codec:commons-codec:1.9',
'commons-collections:commons-collections:3.2.1',
'commons-io:commons-io:2.4',
'commons-logging:commons-logging:1.1.3',
'joda-time:joda-time:2.2',
'org.apache.commons:commons-lang3:3.3.2',
'org.apache.httpcomponents:httpclient:4.3.4',
'org.apache.httpcomponents:httpmime:4.3.3',
'org.bouncycastle:bcprov-jdk15on:1.48',
'org.codehaus.groovy:groovy-all:2.3.6',
'org.codehaus.jackson:jackson-core-asl:1.7.1',
'org.codehaus.jackson:jackson-mapper-asl:1.7.1',
'org.eclipse.jetty:jetty-http:8.1.15.v20140411',
'org.freemarker:freemarker:2.3.21',
'org.objenesis:objenesis:2.1',
'org.seleniumhq.selenium:selenium-api:2.44.0',
'org.slf4j:slf4j-api:1.7.5',
'xalan:xalan:2.7.1',
'xml-apis:xml-apis:1.4.01'
'com.fasterxml.jackson.core:jackson-annotations:2.4.3',
'com.google.code.gson:gson:2.3',
'com.google.guava:guava:18.0',
'com.google.inject.extensions:guice-multibindings:3.0',
'com.google.inject.extensions:guice-servlet:3.0',
'com.google.inject:guice:3.0',
'com.thoughtworks.xstream:xstream:1.4.1',
'commons-codec:commons-codec:1.9',
'commons-collections:commons-collections:3.2.1',
'commons-io:commons-io:2.4',
'commons-logging:commons-logging:1.1.3',
'joda-time:joda-time:2.2',
'org.apache.commons:commons-lang3:3.3.2',
'org.apache.httpcomponents:httpclient:4.3.4',
'org.apache.httpcomponents:httpmime:4.3.3',
'org.bouncycastle:bcprov-jdk15on:1.48',
'org.codehaus.groovy:groovy-all:2.3.6',
'org.codehaus.jackson:jackson-core-asl:1.7.1',
'org.codehaus.jackson:jackson-mapper-asl:1.7.1',
'org.eclipse.jetty:jetty-http:8.1.15.v20140411',
'org.freemarker:freemarker:2.3.21',
'org.objenesis:objenesis:2.1',
'org.seleniumhq.selenium:selenium-api:2.44.0',
'org.slf4j:slf4j-api:1.7.5',
'xalan:xalan:2.7.1',
'xml-apis:xml-apis:1.4.01'
}
}
}
Expand Down Expand Up @@ -165,7 +165,9 @@ subprojects {

dependencies {
compile "com.google.guava:guava:18.0"
compile "com.google.inject:guice:3.0"
compile("com.google.inject:guice:3.0") {
exclude module:"asm"
}
compile "commons-codec:commons-codec:1.9"
compile "org.objenesis:objenesis:2.1"
compile "org.slf4j:slf4j-api:1.7.5"
Expand Down
21 changes: 11 additions & 10 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ext {
jar {
manifest {
attributes("Implementation-Title": "Serenity Core",
"Implementation-Version": project.version.toString())
"Implementation-Version": project.version.toString())
}
}

Expand All @@ -33,14 +33,18 @@ dependencies {

compile ("com.opera:operadriver:1.5") {
exclude group: 'org.seleniumhq.selenium', module:'selenium-java'
exclude group: 'org.seleniumhq.selenium', module:'selenium-remote-driver'
exclude group: 'org.seleniumhq.selenium', module:'selenium-remote-driver' +
''
exclude group: 'com.google.guava', module: 'guava'
}

compile ("org.seleniumhq.selenium:selenium-server:$seleniumVersion") {
exclude group: 'cglib', module: 'cglib-nodep'
exclude group: 'guava', module: 'guava'
exclude group: 'commons-io', module: 'commons-io'
exclude group: 'commons-codec', module: 'commons-codec'
exclude group: 'org.apache.commons', module: 'commons-lang3'
exclude group: 'com.google.code.gson', module: 'gson'
}

compile ('com.github.detro:phantomjsdriver:1.2.0') {
Expand All @@ -59,7 +63,7 @@ dependencies {
exclude group: 'org.objenesis', module: 'objenesis'
}
compile "com.google.guava:guava:18.0"
compile "joda-time:joda-time:2.0"
compile "joda-time:joda-time:2.2"
compile "com.thoughtworks.xstream:xstream:1.4.1"
compile "org.apache.commons:commons-lang3:3.3.2"
compile "commons-collections:commons-collections:3.2.1"
Expand All @@ -74,15 +78,12 @@ dependencies {
compile 'org.hamcrest:hamcrest-library:1.3'
compile "com.thoughtworks.xstream:xstream:1.4.1"
compile "commons-collections:commons-collections:3.2.1"
compile ("org.apache.httpcomponents:httpclient:4.3.4") {
exclude group: 'commons-codec', module: 'commons-codec'
}
compile "org.apache.commons:commons-lang3:3.0.1"
compile "net.sf.flexjson:flexjson:2.1"
compile "joda-time:joda-time:2.0"
compile ("net.sourceforge.htmlunit:htmlunit:2.15") {
exclude group: 'org.apache.commons', module: 'commons-lang3'
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'xml-apis', module: 'xml-apis'
exclude group: 'commons-codec', module: 'commons-codec'
}
compile "org.freemarker:freemarker:2.3.21"
compile("org.fluentlenium:fluentlenium-core:0.10.2") {
Expand All @@ -92,7 +93,7 @@ dependencies {
compile "com.jhlabs:filters:2.0.235"
compile "org.asciidoctor:asciidoctor-java-integration:0.1.3"
compile "com.google.code.gson:gson:2.2.4"
compile "junit:junit:4.11"
compile "junit:junit:4.12"
compile "javax.validation:validation-api:1.1.0.Final"
compile "org.hibernate:hibernate-validator:5.1.1.Final"
compile "javax.el:javax.el-api:2.2.4"
Expand All @@ -116,7 +117,7 @@ dependencies {
}

processResources {
filter ReplaceTokens, tokens: [
filter ReplaceTokens, tokens: [
"application.version": "" + version
]
}
Expand Down
62 changes: 31 additions & 31 deletions core/src/main/java/net/serenitybdd/core/pages/WebElementFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,93 +14,93 @@
@ImplementedBy(WebElementFacadeImpl.class)
public interface WebElementFacade extends WebElement, WrapsElement, Locatable, WebElementState {

public abstract WebElementFacade then(String xpathOrCssSelector);
public <T extends WebElementFacade> T then(String xpathOrCssSelector);

public abstract WebElementFacade findBy(String xpathOrCssSelector);
public <T extends WebElementFacade> T findBy(String xpathOrCssSelector);

public abstract List<WebElementFacade> thenFindAll(
public List<WebElementFacade> thenFindAll(
String xpathOrCssSelector);

public abstract WebElementFacade findBy(By selector);
public <T extends WebElementFacade> T findBy(By selector);

public abstract WebElementFacade find(By bySelector);
public <T extends WebElementFacade> T find(By bySelector);

public abstract WebElementFacade then(By bySelector);
public <T extends WebElementFacade> T then(By bySelector);

public abstract String getAttribute(String name);
public String getAttribute(String name);

public abstract List<WebElementFacade> thenFindAll(By selector);
public List<WebElementFacade> thenFindAll(By selector);

public abstract long getTimeoutInMilliseconds();
public long getTimeoutInMilliseconds();

public abstract WebElementFacade withTimeoutOf(int timeout,
public <T extends WebElementFacade> T withTimeoutOf(int timeout,
TimeUnit unit);

/**
* Convenience method to chain method calls more fluently.
*/
public abstract WebElementFacade and();
public <T extends WebElementFacade> T and();

/**
* Convenience method to chain method calls more fluently.
*/
public abstract WebElementFacade then();
public <T extends WebElementFacade> T then();

public abstract List<String> getSelectOptions();
public List<String> getSelectOptions();

/**
* Type a value into a field, making sure that the field is empty first.
*
* @param value
*/
public abstract WebElementFacade type(String value);
public <T extends WebElementFacade> T type(String value);

/**
* Type a value into a field and then press Enter, making sure that the field is empty first.
*
* @param value
*/
public abstract WebElementFacade typeAndEnter(String value);
public <T extends WebElementFacade> T typeAndEnter(String value);

/**
* Type a value into a field and then press TAB, making sure that the field is empty first.
* This currently is not supported by all browsers, notably Firefox.
*
* @param value
*/
public abstract WebElementFacade typeAndTab(String value);
public <T extends WebElementFacade> T typeAndTab(String value);

public abstract void setWindowFocus();
public void setWindowFocus();

public abstract WebElementFacade selectByVisibleText(String label);
public <T extends WebElementFacade> T selectByVisibleText(String label);

public abstract WebElementFacade selectByValue(String value);
public <T extends WebElementFacade> T selectByValue(String value);

public abstract WebElementFacade selectByIndex(int indexValue);
public <T extends WebElementFacade> T selectByIndex(int indexValue);

public abstract WebElementFacade waitUntilVisible();
public <T extends WebElementFacade> T waitUntilVisible();

public abstract WebElementFacade waitUntilPresent();
public <T extends WebElementFacade> T waitUntilPresent();

public abstract Wait<WebDriver> waitForCondition();
public Wait<WebDriver> waitForCondition();

public abstract WebElementFacade waitUntilNotVisible();
public <T extends WebElementFacade> T waitUntilNotVisible();

public abstract String getValue();
public String getValue();

public abstract String getText();
public String getText();

public abstract WebElementFacade waitUntilEnabled();
public <T extends WebElementFacade> T waitUntilEnabled();

public abstract WebElementFacade waitUntilDisabled();
public <T extends WebElementFacade> T waitUntilDisabled();

/**
* Wait for an element to be visible and enabled, and then click on it.
*/
public abstract void click();
public void click();

public abstract void clear();
public void clear();

public abstract String toString();
public String toString();

}
Loading

0 comments on commit 068315f

Please sign in to comment.