Invoking WebDriver inside a Web Application

42 views
Skip to first unread message

Charles Wesley

unread,
Apr 26, 2016, 9:36:42 AM4/26/16
to Selenium Users

Is it possible to instantiate a WebDriver object from inside a web application?  Our team has a Maven Java project where we instantiate a WebDriver object to perform some UI-based configuration on our behalf.  Now we want to take some of the classes from that project, compile them, and call them from within a web application.  Is this feasible?

David

unread,
Apr 26, 2016, 7:58:52 PM4/26/16
to Selenium Users
Technically yes, but you have no real "display/UI" to work with under a web application (user account). You'd have to workaround that with x11 routing (e.g. like run FirefoxDriver on Linux headless) or use PhantomJS or HTMLUnitDriver which are headless.

Or another option is to instantiate a RemoteWebDriver object to connect to Selenium running remotely on another machine (Selenium grid setup or not), not the web application server itself. This approach would work out of the box on your web app side.

Andreas Tolfsen

unread,
Apr 27, 2016, 5:40:15 AM4/27/16
to seleniu...@googlegroups.com
Tue, 26 Apr 2016 06:36:41 -0700 (PDT) Charles Wesley
<charles...@gmail.com>:
> Is it possible to instantiate a WebDriver object from inside a web
> application? Our team has a Maven Java project where we instantiate
> a WebDriver object to perform some UI-based configuration on our
> behalf.

If what you want to achieve is to re-use the session that started and
controls the browser from within a content document, you may be
interested in WebDriver.js.

It implements a “meta-circular” client that allows an in-content JS
client to assume control over the existing WebDriver session. This
would let you control the browser from within the document.

> Now we want to take some of the classes from that project,
> compile them, and call them from within a web application. Is this
> feasible?

What you’re talking about here is a content JS-to-Java bridge. I’m not
sure about the feasibility of that. What you’d need is a wire protocol
for the document to be able to RPC the Java process. This is, in
essence, what WebDriver provides for the WebDriver API.
Reply all
Reply to author
Forward
0 new messages