Skip to content

Commit

Permalink
Merge branch 'master' into feature/PageUrlAnnotation
Browse files Browse the repository at this point in the history
  • Loading branch information
filipcynarski committed Apr 2, 2016
2 parents 9f1a2c7 + 7b8b8e6 commit 1e23910
Show file tree
Hide file tree
Showing 39 changed files with 598 additions and 435 deletions.
8 changes: 4 additions & 4 deletions README.markdown → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ To add FluentLenium to your project, just add the following dependency to your `
<dependency>
<groupId>org.fluentlenium</groupId>
<artifactId>fluentlenium-core</artifactId>
<version>0.11.0-SNAPSHOT</version>
<version>0.11.0</version>
<scope>test</scope>
</dependency>
```
Expand All @@ -48,7 +48,7 @@ If you need the assertj dependency to improve the legibility of your test code:
<dependency>
<groupId>org.fluentlenium</groupId>
<artifactId>fluentlenium-assertj</artifactId>
<version>0.11.0-SNAPSHOT</version>
<version>0.11.0</version>
<scope>test</scope>
</dependency>
```
Expand All @@ -59,7 +59,7 @@ An adapter has also been built for using FluentLenium with TestNG:
<dependency>
<groupId>org.fluentlenium</groupId>
<artifactId>fluentlenium-testng</artifactId>
<version>0.11.0-SNAPSHOT</version>
<version>0.11.0</version>
<scope>test</scope>
</dependency>
```
Expand Down Expand Up @@ -760,7 +760,7 @@ Be aware that when you modified this elements, the webDriver instance will be mo
### Configuration
You can define a default driver configuration using two ways.
First, just override the getDriver method and use the selenium way to configure your driver.
You can also override the setDefaultConfig method and use both selenium and FluentLenium way (withDefaultSearchWait,withDefaultPageWait) to configure your driver.
You can also override the getDefaultConfig method and use both selenium and FluentLenium way (withDefaultSearchWait,withDefaultPageWait) to configure your driver.

## Browser Lifecycle
For JUnit and TestNG, you can define the browser lifecycle.
Expand Down
15 changes: 15 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
v0.11.0

- #182 - Add a helper method to open a url in a new tab
- #189 - Add getTextContent method to display text content of an element
- #190 - Add xml-apis dependency for tests
- #195 - add missing generic type parameter
- #212 - Add takeHtmlDump method and refactor screenshot triggers to make it available with TestNg
- #214 - Add instructions to run tests on BrowserStack
- #215 - Implemented isClickable() for waiting.
- #225, #226 - Extend find to use By locator
- #224 - Add methods to navigate through document hierarchy
- #222 - FluentWebElement.parent(), .next(), .previous()
- #219, #228 - Add as (Component.class) object into code base
- #227 - Selenium upgrade to 2.53 version

v0.10.9
- fix #60 withValues will be an alias for with method which is restricted word in Scala
- parallel execution on method level will start working since this version, README file extended for examples
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.fluentlenium.core;
package org.fluentlenium.adapter;

import org.fluentlenium.core.Fluent;
import org.fluentlenium.core.FluentPage;
import org.fluentlenium.core.FluentThread;
import org.fluentlenium.core.page.PageInitializerException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
Expand All @@ -8,23 +11,26 @@ public class FluentAdapter extends Fluent {

public FluentAdapter(WebDriver webDriver) {
super(webDriver);
FluentThread.set(this);
}

public FluentAdapter() {
super();
FluentThread.set(this);
}

protected void initTest() {
protected void init() {
try {
pageInitializer.initContainer(this);
} catch (ClassNotFoundException e) {
throw new PageInitializerException("Class not found", e);
} catch (IllegalAccessException e) {
throw new PageInitializerException("IllegalAccessException", e);
}
getDefaultConfig();
}

protected void cleanUp() {
protected void close() {
pageInitializer.release();
}

Expand Down Expand Up @@ -53,13 +59,4 @@ public String getDefaultBaseUrl() {
*/
public void getDefaultConfig() {
}

/**
* @deprecated use FluentPage.isAt() instead.
*
*/
@Deprecated
public static void assertAt(FluentPage fluent) {
fluent.isAt();
}
}
Original file line number Diff line number Diff line change
@@ -1,125 +1,42 @@
package org.fluentlenium.adapter;

import org.fluentlenium.adapter.util.ShutdownHook;
import org.fluentlenium.core.FluentAdapter;
import org.fluentlenium.core.FluentPage;
import org.junit.AfterClass;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.openqa.selenium.WebDriver;

import static org.fluentlenium.adapter.util.SharedDriverHelper.*;

/**
* All Junit Test should extends this class. It provides default parameters.
*/
public abstract class FluentTest extends FluentAdapter {
private static WebDriver sharedDriver;
private static boolean isSharedDriverPerClass;

public abstract class FluentTest extends FluentTestRunnerAdapter {
@Rule
public TestName name = new TestName();
@Rule
public TestRule watchman = new TestWatcher() {
@Override
public void starting(Description description) {
super.starting(description);
//TODO Refactor
if (isSharedDriverOnce(description.getTestClass())) {
synchronized (this) {
if (sharedDriver == null) {
initFluentFromDefaultDriver();
sharedDriver = getDriver();
killTheBrowserOnShutdown();
} else {
initFluentWithExistingDriver();
}
}
} else if (isSharedDriverPerClass(description.getTestClass())) {
synchronized (this) {
if (!isSharedDriverPerClass) {
initFluentFromDefaultDriver();
sharedDriver = getDriver();
isSharedDriverPerClass = true;
} else {
initFluentWithExistingDriver();
}
}
} else {
initFluentFromDefaultDriver();
}

initTest();
setDefaultConfig();
FluentTest.this.starting(description.getTestClass(), description.getDisplayName());
}


@Override
public void finished(Description description) {
super.finished(description);
if (isSharedDriverPerMethod(description.getTestClass()) ||
isDefaultSharedDriver(description.getTestClass())) {
quit();
} else if (isDeleteCookies(description.getTestClass())) {
if (sharedDriver != null) {
sharedDriver.manage().deleteAllCookies();
}
}
FluentTest.this.finished(description.getTestClass(), description.getDisplayName());
}

@Override
public void failed(Throwable e, Description description) {
if (screenshotMode == TriggerMode.ON_FAIL) {
takeScreenShot(description.getTestClass().getSimpleName() + "_" +
description.getMethodName() + ".png");
}
if (htmlDumpMode == TriggerMode.ON_FAIL) {
takeHtmlDump(description.getTestClass().getSimpleName() + "_"
+ description.getMethodName() + ".html");
}
super.failed(e, description);
FluentTest.this.failed(e, description.getTestClass(), description.getDisplayName());
}

};

private void killTheBrowserOnShutdown() {
Runtime.getRuntime().addShutdownHook(new ShutdownHook("fluentlenium", this));
}

private void initFluentWithExistingDriver() {
initFluent(sharedDriver).withDefaultUrl(getDefaultBaseUrl());
}

private void initFluentFromDefaultDriver() {
initFluent(getDefaultDriver()).withDefaultUrl(getDefaultBaseUrl());
}


public FluentTest() {
super();
}


@AfterClass
public static void afterClass() {
if (isSharedDriverPerClass) {
sharedDriver.quit();
sharedDriver = null;
isSharedDriverPerClass = false;
}
FluentTestRunnerAdapter.releaseSharedDriver();
}

/**
* Override this method to change the default time to wait for a page to be loaded
*/
public void setDefaultConfig() {
}

public static void assertAt(FluentPage fluent) {
fluent.isAt();
}


}
Loading

0 comments on commit 1e23910

Please sign in to comment.