JBoss Community Archive (Read Only)

Graphene 2

Graphene Context and Proxy

Graphene stores WebDriver instance in the thread-local context, distinguished by browser qualifier.

It enables to write framework-like features where context of the browser is injected just when you need it:

Accessing

To access a browser session, you can obtain proxy of the context,

which is proxy object which delegates the methods you call on an instance which is at the time available in the context of current thread.

The most generic form is obtaining instance of WebDriver:

WebDriver browser = GrapheneContext.getContextFor(Default.class).getWebDriver();

The Default.class representas a browser's qualifier - in this case we are requesting default browser (when no qualifier is specified on Drone instances). Read more in Parallel browsers.

You can also use alternative methods, most notably the method which provides proxy object implementing given extension interfaces:

JavascriptExecutor executor = (JavascriptExecutor) GrapheneContext.getContextFor(Default.class).getWebDriver(JavascriptExecutor.class)
JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-10 12:14:40 UTC, last content change 2013-09-16 09:57:15 UTC.