jQuery-like cross-driver interface in Java for Selenium WebDriver

Overview

seleniumQuery

Maven Central

Codacy Badge codecov.io GitHub license Join the chat at https://gitter.im/seleniumQuery/seleniumQuery

Run Status

Sauce Test Status

Feature-rich jQuery-like Java interface for Selenium WebDriver

seleniumQuery is a feature-rich cross-driver Java library that brings a jQuery-like interface for Selenium WebDriver.

It is designed to be a thin layer over Selenium. You can use seleniumQuery to manage the WebDriver for you, or you can use seleniumQuery on top of your favorite selenium framework just to make some cases simpler when needed.

Example snippet:

// Regular Selenium
WebElement el  = driver.findElement(By.cssSelector(".street"));
String oldStreet = element.getAttribute("value"); // what if ".street" is a <select>? this won't work
element.setAttribute("value", "4th St!")

// seleniumQuery
// getting the value
String oldStreet = $(".street").val(); // works even if it is a <select>, <textarea>, etc.
// setting the value
$("input.street").val("4th St!"); // also would work for a <select>

And much more. The example above is of something that has an equivalent in Selenium. Not everything does (many things would require tons of boilerplate in vanilla Selenium).

No special configuration needed - use seleniumQuery's goodies in your project right now:

On a regular WebElement...

// an existing WebElement...
WebElement existingWebElement = driver.findElement(By.id("myId"));
// call jQuery functions
String elementVal = $(existingWebElement).val();
boolean isButton = $(existingWebElement).is(":button"); // enhanced selector!
for (WebElement child: $(existingWebElement).children()) {
  System.out.println("That element's child: "+child);
}

Or an existing WebDriver...

// an existing WebDriver...
WebDriver driver = new FirefoxDriver();
// set it up
$.driver().use(driver);
// and use all the goods
for (WebElement e: $(".myClass:contains('My Text!'):not(:button)")) {
  System.out.println("That element: " + e);
}

What can you do with it?

Allows querying elements by:

  • CSS3 Selectors - $(".myClass"), $("#table tr:nth-child(3n+1)");
  • jQuery enhanced selectors - $(":text:eq(3)"), $(".myClass:contains('My Text!')");
  • XPath - $("//div/*/label/preceding::*");
  • and even some own seleniumQuery selectors: $("#myOldDiv").is(":not(:present)").

Built using Selenium WebDriver's capabilities, no jQuery.js is embedded at the page, no side-effects are generated.



Quickstart: A running example

Try it out now with the running example below:

import static io.github.seleniumquery.SeleniumQuery.$; // this will allow the short syntax

public class SeleniumQueryExample {
  public static void main(String[] args) {
    // The WebDriver will be instantiated only when first used
    $.driver()
        .useChrome() // sets Chrome as the driver (this is optional, if omitted, will default to HtmlUnit)
        .headless() // configures chrome to be headless
        .autoDriverDownload() // automatically downloads and configures chromedriver.exe
        .autoQuitDriver(); // automatically quits the driver when the JVM shuts down

    // or, instead, use any previously existing driver
    // $.driver().use(myExistingInstanceOfWebDriver);

    // starts the driver (if not started already) and opens the URL
    $.url("http://www.google.com/?hl=en");

    // interact with the page
    $(":text[name='q']").val("seleniumQuery"); // the keys are actually typed!

    // Besides the short syntax and the jQuery behavior you already know,
    // other very useful function in seleniumQuery is .waitUntil(),
    // handy for dealing with user-waiting actions (specially in Ajax enabled pages):

    // the command below waits until the button is visible and then performs a real user click (not just the JS event)
    $(":button[value='Google Search']").waitUntil().isVisible().then().click();

    // this waits for the #resultStats to be visible using a selector and, when it is visible, returns its text content
    String resultsText = $("#resultStats").waitUntil().is(":visible").then().text();

    // .assertThat() functions: fluently asserts that the text contains the string "seconds", ignoring case
    $("#resultStats").assertThat().text().containsIgnoreCase("seconds");

    System.out.println(resultsText);
    // should print something like: About 4,100 results (0.42 seconds)

    // $.quit(); // would quit the driver, but it is not needed as .autoQuitDriver() was used
  }
}

To get the latest version of seleniumQuery, add to your pom.xml:

<dependency>
    <groupId>io.github.seleniumquery</groupId>
    <artifactId>seleniumquery</artifactId>
    <version>0.20.0</version>
</dependency>



Looking for more examples?

Download and execute the seleniumQuery showcase project. It contains many demonstrations of what seleniumQuery is capable of.


Features

seleniumQuery implements all jQuery functions that are useful to browser manipulation. On top of it, we add many other useful functions (see $("selector").waitUntil() and $("selector").assertThat() below).

Our main goal is to make emulating user actions and reading the state of pages easier than ever, with a consistent behavior across drivers.

Readable jQuery syntax you already know

Make your code/tests more readable and easier to maintain. Leverage your knowledge of jQuery.

// Instead of regular Selenium code:
WebElement element = driver.findElement(By.id("mySelect"));
new Select(element).selectByValue("ford");

// You can have the same effect writing just:
$("#mySelect").val("ford");

Get to know what jQuery functions seleniumQuery supports and what else it brings to the table on our seleniumQuery API wiki page.


Waiting (ajax testing) and asserting

WebDriver's FluentWait is great, but it requires too much boilerplate code. Enters the .waitUntil() function:

// Below is an example of a <div> that should be hidden as effect of an Ajax call.
// The code will hold until the modal is gone. If it is never gone, seleniumQuery will throw a timeout exception
$("#modalDiv :button:contains('OK')").click();
$("#modalDiv :button:contains('OK')").waitUntil().is(":not(:visible)");
// Or the two commands above, fluently:
$("#modalDivOkButton").click().waitUntil().is(":not(:visible)");

You can also assert directly into the seleniumQuery object using .assertThat():

$("#modalDiv :button:contains('OK')").assertThat().is(":not(:visible)");
$("#myInput").assertThat().val().isBlank();

Any function that can be used with $().waitUntil() can also be used with $().assertThat() and vice-versa. See below, expand (click on the arrow) each item for more details.

$(). function Property/Evaluation Function Evaluation Function
.waitUntil()

In order to handle interactions with Ajax-enabled pages, you can use the .waitUntil() function:

  • The .waitUntil() functions will requery the DOM for the elements until the given condition is met, returning a new seleniumQuery object when that happens.
// .waitUntil() will requery the DOM every time until the matched set fulfills the requirements

// .is() functions
$(".aDivDiv").waitUntil().is(":present");
$(".myInput").waitUntil().is(":enabled");
$(".aDivDiv").waitUntil().is(":visible");
$(".myInput").waitUntil().is(":visible:enabled");
// functions such as .val(), .text() and others are also available
$(".myInput").waitUntil().val().isEqualTo("expectedValue");
$(".aDivDiv").waitUntil().text().contains("expectedText");
// and more...
$(".myInput").waitUntil().val().matches(".*\d{10}\*");
$(".myInput").waitUntil().size().isGreaterThan(7);
$(".aDivDiv").waitUntil().html().contains("<div>expected</div>");
.assertThat()

Asserts, fluently, that the function has a specified value or matches a specified condition.

$("#stuff").assertThat().val().isEqualTo("expectedValue");
$(".m-e").assertThat().attr("attrName").isEqualTo("expectedValue");
$("span").assertThat().size().isGreaterThan(7);
$("#age").assertThat().val().matches(".*\d{10}\*");
$("#ipt").assertThat().val().matches(value -> value.length() > 50)
.val()
$(".myInput").assertThat().val().isEqualTo("expectedValue");
.text()
$(".div").assertThat().text().isEqualTo("expectedValue");
.attr("attrName")
$(".myInput").assertThat().attr("attrName").isEqualTo("expectedValue");
.prop("propName")
$(".myInput").assertThat().prop("propName").isEqualTo("expectedValue");
.html()
$(".div").assertThat().html().isEqualTo("expectedValue");
.size()
$(".div").assertThat().size().isEqualTo(0);
.isEqualTo("string" | <number> | other)
$(".myInput").assertThat().val().isEqualTo("expectedValue");
.isBlank()

Tests if the result of the preceding function is empty (""), null or whitespace only:

(null).isBlank()      = true
("").isBlank()        = true
(" ").isBlank()       = true
("bob").isBlank()     = false
("  bob  ").isBlank() = false

Example:

$(".myInput").assertThat().text().isBlank();
.isGreaterThan(<number>)
$(".myInput").assertThat().size().isGreaterThan(7);
.isLessThan(<number>)
$(".myInput").assertThat().size().isGreaterThan(7);
.contains("string")
$(".aDivDiv").waitUntil().html().contains("<div>expected</div>");
$(".aDivDiv").assertThat().text().contains("expectedText");
.containsIgnoreCase("string")
$(".aDivDiv").assertThat().text().containsIgnoreCase("eXpeCTedText");
.matches("string regex")
$(".myInput").assertThat().val().matches(".*\d{10}\*");
$("...").waitUntil().html().matches("my[0-9]regex.*?");
.matches(java.util.Pattern)
$("...").assertThat().val().matches(java.util.Pattern);
.matches(<Hamcrest Matcher>)
$("#myDiv").waitUntil().text().matches(Matchers.containsString("John"));
.matches(<lambda predicate>)
$("#ipt").waitUntil().val().matches(value -> value.length() > 50)
.is("selector")
$(".myInput").assertThat().is(":disabled");
$(".myInput").assertThat().is(":visible:enabled");
.isEmpty()

Evaluates if the size of this seleniumQuery is equal to zero.

 $("div").waitUntil().isEmpty();
 $("div").assertThat().isEmpty();
.isNotEmpty()

Evaluates if the size of this seleniumQuery is greated than zero.

 $("div").waitUntil().isNotEmpty();
 $("div").assertThat().isNotEmpty();
.isPresent()

Evaluates if this seleniumQuery object has elements (is not empty).

Note: this is an alias to .isNotEmpty().

 $("div").waitUntil().isPresent();
 $("div").assertThat().isPresent();
.isVisible()

Evaluates if this seleniumQuery object has only visible elements.

Note: this is different from .is(":visible") because .is() requires only one element to match the selector (to be visible), whereas this .isVisible() method requires all matched elements to be visible.

$("span.all-visible").waitUntil().isVisible();
$("span.all-visible").assertThat().isVisible();
.isDisplayed()

Evaluates if this seleniumQuery object has only visible elements.

Note: this is different from .is(":visible") because .is() requires only one element to match the selector (to be visible), whereas this .isVisible() method requires all matched elements to be visible.

This is an alias to .isVisible().

$("span.all-visible").waitUntil().isDisplayed();
$("span.all-visible").assertThat().isDisplayed();
.isHidden()

Evaluates if this seleniumQuery object is not empty and has only hidden elements.

Note: while .isNotVisible() considers an empty set a success, this method doesn't.

$("span.non-empty-and-all-hidden").waitUntil().isHidden();
$("span.non-empty-and-all-hidden").assertThat().isHidden();
.isNotVisible()

Evaluates if this seleniumQuery object is empty or has only hidden elements.

Note: while .isHidden() considers an empty set a failure, this method doesn't.

$("span.empty-or-all-hidden").waitUntil().isNotVisible();
$("span.empty-or-all-hidden").assertThat().isNotVisible();

You can also chain calls using .and():

$("span").assertThat().size().isGreaterThan(5).and().text().isEqualTo("a b c d e");

Or use functions after waiting/asserting using .then():

$("#div").waitUntil().isVisible().then().click();



Flexible WebDriver builder system

How to setup the WebDriver? Simply use our builder. You can download their executables before or you can let seleniumQuery automatically download and configure them. Setup in seleniumQuery is all too easy:

// Using Chrome, general example:
$.driver()
    .useChrome() // configures Chrome as the driver
    .headless() // configures Chrome to run in headless mode
    .autoDriverDownload() // automatically downloads and configures chromedriver.exe
    .autoQuitDriver(); // automatically quits the driver when the JVM shuts down

// Using Firefox
$.driver()
    .useFirefox() // configures Firefox as the driver
    .headless() // configures Firefox to run in headless mode
    .autoDriverDownload() // automatically downloads and configures geckodriver.exe
    .autoQuitDriver(); // automatically quits the driver when the JVM shuts down

For more examples, options and all supported drivers, see table below.

Existing WebDriver Instance

Using seleniumQuery in an existing WebDriver instance

The driver builder functions are a bonus, you don't have to use them. For seleniumQuery, it makes no difference.

If you want to create the WebDriver yourself or add seleniumQuery to an existing WebDriver instance just:

WebDriver myExistingDriverInstance = ...; // created elsewhere by whoever

$.driver().use(myExistingDriverInstance); // from now on, $ will work on myExistingDriverInstance

// now you can use all of seleniumQuery's power!
$("#phone").assertThat().val().isEqualTo("99887766");

chrome

Chrome

Here's how seleniumQuery can simplify a ChromeDriver instantiation.

Headless mode available. Automatic driver download available.

.useChrome()

Configures Chrome as the driver to be used. Provides additional configuration options that can be chained.

Calling $.driver().useChrome() does not instantiate the driver right away, it merely configures it. The driver will be instantiated when first used only (e.g. when $.url("http://somepage") is called).

.headless()

Runs Chrome in headless mode.

.autoQuitDriver()

Automatically quits the driver upon JVM shutdown.

If you don't use .autoQuitDriver(), you can quit the driver calling $.quit().

Having .autoQuitDriver() on and still calling $.quit() makes no harm, so quit at will.

.autoDriverDownload()

seleniumQuery automatically downloads and configures the driver. The download is managed by webdrivermanager. Additional options are available, pass a lambda to .autoDriverDownload(<labda>) to be able to configure:

$.driver().useChrome().autoDriverDownload((BrowserManager configurer) -> {
    // se more options at https://github.com/bonigarcia/webdrivermanager#webdrivermanager-api
    configurer.proxy("http://corpproxy:8182");
    configurer.proxyUser("myUser");
    configurer.proxyPass("myPass")
});
.withOptions(ChromeOptions)

Enables additional configuration through a ChromeOptions instance.

.withPathToChromeDriver(String)

If you don't want seleniumQuery to automatically download the executable for you (using .autoDriverDownload()) you can specify the location of chromedriver.exe/chromedriver yourself:

$.driver().useChrome().withPathToChromeDriver("path/to/chromedriver.exe");

If you use neither .autoDriverDownload() nor .withPathToChromeDriver(), seleniumQuery will attempt to find the executable on your PATH or classpath. If it doesn't find it anywhere, an exception will be thrown.

.withCapabilities(DesiredCapabilities)

Configures the given DesiredCapabilities in the driver to be instantiated. Prefer ChromeOptions when possible.


// Using Chrome
$.driver().useChrome(); // will look for chromedriver/exe to you, including in the classpath!
// if you don't have chromedriver.exe and want seleniumQuery to auto download and configure it
$.driver().useChrome().headless().autoDriverDownload();
// If you want to set the path to chromedriver.exe yourself
$.driver().useChrome().withPathToChromeDriver("path/to/chromedriver.exe")
// General example:
$.driver()
    .useChrome() // configures Chrome as the driver
    .headless() // configures Chrome to run in headless mode
    .autoDriverDownload() // automatically downloads and configures chromedriver.exe
    .autoQuitDriver(); // automatically quits the driver when the JVM shuts down
// using options
$.driver()
    .useChrome()
    .withOptions(<some ChromeOptions instance>)

firefox

Firefox

Easy FirefoxDriver instantiation and configuration with seleniumQuery.

Headless mode available. Automatic driver download available.

.useFirefox()

Configures Firefox as the driver to be used. Provides additional configuration options that can be chained.

Calling $.driver().useFirefox() does not instantiate the driver right away, it merely configures it. The driver will be instantiated when first used only (e.g. when $.url("http://somepage") is called).

.headless()

Runs Firefox in headless mode.

.autoQuitDriver()

Automatically quits the driver upon JVM shutdown.

If you don't use .autoQuitDriver(), you can quit the driver calling $.quit().

Having .autoQuitDriver() on and still calling $.quit() makes no harm, so quit at will.

.autoDriverDownload()

seleniumQuery automatically downloads and configures the driver. The download is managed by webdrivermanager. Additional options are available, pass a lambda to .autoDriverDownload(<labda>) to be able to configure:

$.driver().useFirefox().autoDriverDownload((BrowserManager configurer) -> {
    // se more options at https://github.com/bonigarcia/webdrivermanager#webdrivermanager-api
    configurer.proxy("http://corpproxy:8182");
    configurer.proxyUser("myUser");
    configurer.proxyPass("myPass")
});
.withOptions(FirefoxOptions)

Enables additional configuration through a FirefoxOptions instance.

.withBinary(FirefoxBinary)

Enables additional configuration through a FirefoxBinary instance.

.withProfile(FirefoxProfile)

Enables additional configuration through a FirefoxProfile instance.

.withCapabilities(DesiredCapabilities)

Configures the given DesiredCapabilities in the driver to be instantiated. Prefer FirefoxOptions when possible.


// Using Firefox
$.driver()
    .useFirefox() // configures Firefox as the driver
    .headless() // configures Firefox to run in headless mode
    .autoDriverDownload() // automatically downloads and configures geckodriver.exe
    .autoQuitDriver(); // automatically quits the driver when the JVM shuts down
// simplified setting of profile, options and binary
$.driver()
    .useFirefox()
    .withProfile(<an instance of FirefoxProfile>)
    .withOptions(<an instance of FirefoxOptions>)
    .withBinary(<an instance of FirefoxBinary>);

opera

Opera

Automatic driver download available.

.useOpera()

Configures Opera as the driver to be used. Provides additional configuration options that can be chained.

Calling $.driver().useOpera() does not instantiate the driver right away, it merely configures it. The driver will be instantiated when first used only (e.g. when $.url("http://somepage") is called).

.autoQuitDriver()

Automatically quits the driver upon JVM shutdown.

If you don't use .autoQuitDriver(), you can quit the driver calling $.quit().

Having .autoQuitDriver() on and still calling $.quit() makes no harm, so quit at will.

.autoDriverDownload()

seleniumQuery automatically downloads and configures the driver. The download is managed by webdrivermanager. Additional options are available, pass a lambda to .autoDriverDownload(<labda>) to be able to configure:

$.driver().useOpera().autoDriverDownload((BrowserManager configurer) -> {
    // se more options at https://github.com/bonigarcia/webdrivermanager#webdrivermanager-api
    configurer.proxy("http://corpproxy:8182");
    configurer.proxyUser("myUser");
    configurer.proxyPass("myPass")
});
.withOptions(OperaOptions)

Enables additional configuration through a OperaOptions instance.

.withBinary(string | File)

Configures the Opera browser binary location. Example:

$.driver().useOpera().autoDriverDownload()
    .withBinary("C:/Program Files/Opera/49.0.2725.47/opera.exe");
.withCapabilities(DesiredCapabilities)

Configures the given DesiredCapabilities in the driver to be instantiated. Prefer OperaOptions when possible.


// Opera
// we'll download the driver for you
$.driver().useOpera().autoDriverDownload();
// simplified setting of options and binary
$.driver()
    .useOpera()
    .withOptions(<an instance of OperaOptions>)
    .withBinary("C:/Program Files/Opera/49.0.2725.47/opera.exe") // example path
    .autoDriverDownload();

PhantomJS

PhantomJS

Always headless, webkit-based. Automatic executable download available.

.usePhantomJS()

Configures PhantomJS as the driver to be used. Provides additional configuration options that can be chained.

Calling $.driver().usePhantomJS() does not instantiate the driver right away, it merely configures it. The driver will be instantiated when first used only (e.g. when $.url("http://somepage") is called).

.autoQuitDriver()

Automatically quits the driver upon JVM shutdown.

If you don't use .autoQuitDriver(), you can quit the driver calling $.quit().

Having .autoQuitDriver() on and still calling $.quit() makes no harm, so quit at will.

.autoDriverDownload()

seleniumQuery automatically downloads and configures the driver. The download is managed by webdrivermanager. Additional options are available, pass a lambda to .autoDriverDownload(<labda>) to be able to configure:

$.driver().usePhantomJS().autoDriverDownload((BrowserManager configurer) -> {
    // se more options at https://github.com/bonigarcia/webdrivermanager#webdrivermanager-api
    configurer.proxy("http://corpproxy:8182");
    configurer.proxyUser("myUser");
    configurer.proxyPass("myPass")
});
.withPathToPhantomJS(String)

If you don't want seleniumQuery to automatically download the executable for you (using .autoDriverDownload()) you can specify the location of phantomjs.exe/phantomjs yourself:

$.driver().usePhantomJS().withPathToPhantomJS("path/to/phantomjs.exe");

If you use neither .autoDriverDownload() nor .withPathToPhantomJS(), seleniumQuery will attempt to find the executable on your PATH or classpath. If it doesn't find it anywhere, an exception will be thrown.

.withCapabilities(DesiredCapabilities)

Configures the given DesiredCapabilities in the driver to be instantiated.


// PhantomJS (GhostDriver)
// we'll download phantomjs.exe for you
$.driver().usePhantomJS().autoDriverDownload();
// or, we may find phantomjs[.exe] for you, throwing an error if not present
$.driver().usePhantomJS();  
// Or you may set the path yourself
$.driver().usePhantomJS().withPathToPhantomJS("path/to/phantomjs.exe");

HtmlUnit

HmtlUnit

Always headless, java-based. No need to download anything.

.useHtmlUnit()

Configures HmtlUnit as the driver to be used. Provides additional configuration options that can be chained.

Calling $.driver().useHtmlUnit() does not instantiate the driver right away, it merely configures it. The driver will be instantiated when first used only (e.g. when $.url("http://somepage") is called).

.autoQuitDriver()

Automatically quits the driver upon JVM shutdown.

If you don't use .autoQuitDriver(), you can quit the driver calling $.quit().

Having .autoQuitDriver() on and still calling $.quit() makes no harm, so quit at will.

Note: Since HtmlUnit is a java-based driver, it will quit upon JVM shutdown anyway.

.withoutJavaScript()

Runs HtmlUnit with disabled JavaScript.

.emulatingChrome()

Configures HtmlUnit to emulate Chrome.

.emulatingFirefox()

Configures HtmlUnit to emulate Firefox.

.emulatingInternetExplorer()

Configures HtmlUnit to emulate Internet Explorer.

.withCapabilities(DesiredCapabilities)

Configures the given DesiredCapabilities in the driver to be instantiated.


// There are many possibilities to set up HtmlUnitDriver
// HtmlUnit default (Chrome/JavaScript ON)
$.driver().useHtmlUnit();
// Want disabled JavaScript, just call .withoutJavaScript()
$.driver().useHtmlUnit().withoutJavaScript();

// HtmlUnit emulating Chrome
$.driver().useHtmlUnit().emulatingChrome();
$.driver().useHtmlUnit().emulatingChrome().withoutJavaScript();
// HtmlUnit emulating Firefox
$.driver().useHtmlUnit().emulatingFirefox(); // could disable JS here as well
// And IE
$.driver().useHtmlUnit().emulatingInternetExplorer11(); // JS is disableable as well
$.driver().useHtmlUnit().emulatingInternetExplorer(); // will pick latest IE

safari

Safari

seleniumQuery tests Safari as a remote driver.

$.driver().useDriver(new SafariDriver());

edge

Edge

Automatic driver download available.

.useEdge()

Configures Edge as the driver to be used. Provides additional configuration options that can be chained.

Calling $.driver().useEdge() does not instantiate the driver right away, it merely configures it. The driver will be instantiated when first used only (e.g. when $.url("http://somepage") is called).

.autoQuitDriver()

Automatically quits the driver upon JVM shutdown.

If you don't use .autoQuitDriver(), you can quit the driver calling $.quit().

Having .autoQuitDriver() on and still calling $.quit() makes no harm, so quit at will.

.autoDriverDownload()

seleniumQuery automatically downloads and configures the driver. The download is managed by webdrivermanager. Additional options are available, pass a lambda to .autoDriverDownload(<labda>) to be able to configure:

$.driver().useEdge().autoDriverDownload((BrowserManager configurer) -> {
    // se more options at https://github.com/bonigarcia/webdrivermanager#webdrivermanager-api
    configurer.proxy("http://corpproxy:8182");
    configurer.proxyUser("myUser");
    configurer.proxyPass("myPass")
});
.withOptions(EdgeOptions)

Enables additional configuration through a EdgeOptions instance.

.withCapabilities(DesiredCapabilities)

Configures the given DesiredCapabilities in the driver to be instantiated. Prefer EdgeOptions when possible.


// Edge
// we'll download the driver for you
$.driver().useEdge().autoDriverDownload();
// simplified setting of options
$.driver()
    .useEdge()
    .withOptions(<an instance of EdgeOptions>);

internet explorer

Internet Explorer

Automatic driver download available. Additional info about configuration can be found in our IE Driver wiki.

.useInternetExplorer()

Configures Internet Explorer as the driver to be used. Provides additional configuration options that can be chained.

Calling $.driver().useInternetExplorer() does not instantiate the driver right away, it merely configures it. The driver will be instantiated when first used only (e.g. when $.url("http://somepage") is called).

.autoQuitDriver()

Automatically quits the driver upon JVM shutdown.

If you don't use .autoQuitDriver(), you can quit the driver calling $.quit().

Having .autoQuitDriver() on and still calling $.quit() makes no harm, so quit at will.

.autoDriverDownload()

seleniumQuery automatically downloads and configures the driver. The download is managed by webdrivermanager. Additional options are available, pass a lambda to .autoDriverDownload(<labda>) to be able to configure:

$.driver().useInternetExplorer().autoDriverDownload((BrowserManager configurer) -> {
    // se more options at https://github.com/bonigarcia/webdrivermanager#webdrivermanager-api
    configurer.proxy("http://corpproxy:8182");
    configurer.proxyUser("myUser");
    configurer.proxyPass("myPass")
});
.withPathToIEDriverServerExe(String)

If you don't want seleniumQuery to automatically download the executable for you (using .autoDriverDownload()) you can specify the location of IEDriverServer.exe yourself:

$.driver().useInternetExplorer().withPathToIEDriverServerExe("C:\\IEDriverServer.exe");

If you use neither .autoDriverDownload() nor .withPathToIEDriverServerExe(), seleniumQuery will attempt to find IEDriverServer.exe on your PATH or classpath. If it doesn't find it anywhere, an exception will be thrown.

.withCapabilities(DesiredCapabilities)

Configures the given DesiredCapabilities in the driver to be instantiated.


// InternetExplorerDriver
// we'll download the driver for you
$.driver().useInternetExplorer().autoDriverDownload();
// or we search IEDriverServer.exe on your computer (path and classpash) for you
$.driver().useInternetExplorer();
// Or you set the path yourself
$.driver().useInternetExplorer().withPathToIEDriverServerExe("C:\\IEDriverServer.exe");

Available $("selector").functions()

Check the javadocs for our $().functions.

More info also in our API wiki page.


Available $.functions()

Check the javadocs for our $.functions.

Read about our global functions in the API wiki page.


Powerful selector system

Let the tool do the hard work and find elements easily:

  • CSS3 Selectors - $(".myClass"), $("#table tr:nth-child(3n+1)")
  • jQuery/Sizzle enhancements - $(".claz:eq(3)"), $(".claz:contains('My Text!')")
  • XPath - $("//div/*/label/preceding::*")
  • and even some own seleniumQuery selectors: $("#myOldDiv").is(":not(:present)").

You pick your style. Whatever is more interesting at the moment. Mixing is OK:

$("#tab tr:nth-child(3n+1)").find("/img[@alt='calendar']/preceding::input").val("2014-11-12")

Find more about them in seleniumQuery Selectors wiki page.



seleniumQuery still is Selenium - with "just" a jQuery interface

So there is a important aspect of it: Although our functions yield the same result as if you were using jQuery, remember we always execute them from the user perspective. In other words, when you call:

$(":input[name='email']").val("[email protected]");

We don't change the value attribute directly like jQuery does. We actually do as a user would: We clear the input and type, key by key, the string provided as argument!

And we go the extra mile whenever possible:

  • Our $().val() even works on contenteditable elements AND documentMode=on <iframe>s: They don't have value, but we type the text in them, again, key by key, as an user would;
  • If it is an <input type="file"> we select the file;
  • When the element is a <select>, we choose the <option> by the value given (same as $("selector").as().select().selectByValue("123")).

Always from the user perspective

On the same tone, when selecting/checking <option>s or checkboxes or radios, try not to use $().prop("selected", true) directly to them (which to work, of course, would need JS to be enabled on the driver). Do as an user would: call .click()! Or, better yet, use seleniumQuery's .as().select() functions: $().as().select().selectByVisibleText("My Option") or $().as().select().selectByValue("123").



Using multiple browsers/drivers simultaneously

Typically, the $ is a static variable, thus every command you issue only affects the one same instance of WebDriver.

But... what if you want/need to use two WebDrivers at the same time?

We've got your back, see the example:

public static void main(String[] args) {
  String demoPage = "https://cdn.rawgit.com/seleniumQuery/seleniumQuery-showcase/master/Agent.html";

  // using two drivers (chrome and firefox) at the same time
  SeleniumQueryBrowser chrome = new SeleniumQueryBrowser();
  chrome.$.driver().useHtmlUnit().emulatingChrome().autoQuitDriver();
  chrome.$.url(demoPage);

  SeleniumQueryBrowser firefox = new SeleniumQueryBrowser();
  firefox.$.driver().useHtmlUnit().emulatingFirefox().autoQuitDriver();
  firefox.$.url(demoPage);

  chrome.$("#agent").assertThat().text().contains("Chrome");
  firefox.$("#agent").assertThat().text().contains("Firefox");
}

Plugin System

seleniumQuery supports plugins through the .as(PLUGIN) function, such as:

$("div").as(YOURPLUGIN).someMethodFromYourPlugin();

There are some default plugins. To check them out, call .as() without arguments. Example:

// the .select() plugin
$("#citiesSelect").as().select().selectByVisibleText("New York");
// picks an <option> in the <select> based in the <option>'s visible text

For an example of how to create your own plugin, check the seleniumQuery Plugin wiki page.


Alternate symbols

If the dollar symbol, $, gives you the yikes -- we know, it is used for internal class names --, it is important to notice that the $ symbol in seleniumQuery is not a class name, but a static method (and field). Still, if you don't feel like using it, you can resort to sQ() or good ol' jQuery() and benefit from all the same goodies:

import static io.github.seleniumquery.SeleniumQuery.sQ;
import static io.github.seleniumquery.SeleniumQuery.jQuery;
...
String oldStreet = sQ("input.street").val();
sQ("input.street").val("4th St!");

String oldStreetz = jQuery("input.street").val();
jQuery("input.street").val("5th St!");

More

Find more on our wiki.


Changelog/Roadmap

See releases.

Contributing or Requesting Features

The tool quite simple, so there's a lot of room for improvement. If you think something would be useful for you, it would probably be useful to us all, tell us what you're thinking!

Comments
  • waitUntil() throws InvalidSelectorError: Unable to locate an element with the xpath expression

    waitUntil() throws InvalidSelectorError: Unable to locate an element with the xpath expression

    Hello,

    I try to use seleniumQuery to navigate through a website with dynamically changed content (meaning it changes with page refresh). When I open the website in browser there is a button I need to click, but the button appears only after some time.

    In Selenium IDE I use a waitForElementPresent command to wait for this button to appear before I fire it up. I tried the following code to copy this behaviour in seleniumQuery

     $(".custom-dropdown-arrow-major").waitUntil().is(":present"); // tried also with :visible
    

    But I receive following error:

    Caused by: org.openqa.selenium.InvalidSelectorException: The given selector (.//[contains(concat(' ', normalize-space(@class), ' '), ' custom-dropdown-arrow-major ')]) is either invalid or does not result in a WebElement. The following error occurred: InvalidSelectorError: Unable to locate an element with the xpath expression (.//[contains(concat(' ', normalize-space(@class), ' '), ' custom-dropdown-arrow-major ')]) because of the following error: TypeError: Argument 1 of Document.createNSResolver is not an object.

    Whereas in webdriver this work:

    WebDriverWait wait = new WebDriverWait(driver.get(), 100);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("custom-dropdown-arrow-major")));
    

    [Edit]

    I assume problem starts with $ contructor, where right at the begininng elements are retrieved.

        protected SeleniumQueryObject(WebDriver driver, String selector) {
            this.driver = driver;
            this.by = SeleniumQueryBy.byEnhancedSelector(selector);
            this.elements = toImmutableRandomAccessList(driver.findElements(this.by));
            this.previous = null;
        }
    

    Would it make sense to make this attribute lazy initialized? In that case the exception would not be fired upon $().waitUntil() but at the same time it shouldn't affect the rest of code. I would be happy to make the change if you agree on solution.

    external bug 
    opened by thejavatar 10
  • java.lang.NoSuchMethodError: org.openqa.selenium.remote.DesiredCapabilities.htmlUnitWithJs()Lorg/openqa/selenium/remote/DesiredCapabilities;

    java.lang.NoSuchMethodError: org.openqa.selenium.remote.DesiredCapabilities.htmlUnitWithJs()Lorg/openqa/selenium/remote/DesiredCapabilities;

    public void checkEmailBox() {
            String value = $("document.querySelectorAll(\"input\")[7]").val();
            System.out.println(value);
        }
    

    Is throwing an error that there is no such method. Any ideas?

    opened by any4ka 7
  • Overloaded method to either clear or not for existing driver when calling driver().use()

    Overloaded method to either clear or not for existing driver when calling driver().use()

    Sometime we want not to close the current webdriver and switch between the driver then we cannot just do $.driver().use(webDriver); because it will automatically close the existing driver. So to make it easy we need an extra parameter for developer to either clear or not the existing driver before instantiating the new webdriver.

    $.driver().use(webDriver,false);

    opened by privatejava 6
  • val(text) doesn't work when we try to write text inside an iFrame

    val(text) doesn't work when we try to write text inside an iFrame

    Hi,

    Every time that I want to use the $(element).val(text) in an element like this one:

    screen shot 2016-06-29 at 16 04 11

    I get the following error:

    Caused by: org.openqa.selenium.WebDriverException: Element must be user-editable in order to clear it.
    Build info: version: '2.51.0', revision: '1af067d', time: '2016-02-05 19:15:17'
    System info: host: 'JordiPonss-MacBook-Pro-1194.local', ip: '192.168.38.180', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.5', java.version: '1.8.0_66'
    Driver info: driver.version: unknown
    Command duration or timeout: 500 milliseconds
    Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26'
    System info: host: 'JordiPonss-MacBook-Pro-1194.local', ip: '192.168.38.180', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.5', java.version: '1.8.0_66'
    Driver info: org.openqa.selenium.remote.RemoteWebDriver
    Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=45.2.0, platform=MAC, nativeEvents=false, acceptSslCerts=true, webdriver.remote.sessionid=52a9201d-0867-4fa3-94e9-3202c5f8db5e, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
    Session ID: 52a9201d-0867-4fa3-94e9-3202c5f8db5e
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
        at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
        at org.openqa.selenium.remote.RemoteWebElement.clear(RemoteWebElement.java:113)
        at io.github.seleniumquery.functions.jquery.forms.ValFunction.val(ValFunction.java:131)
        at io.github.seleniumquery.functions.jquery.forms.ValFunction.val(ValFunction.java:87)
        at io.github.seleniumquery.functions.SeleniumQueryFunctions.valueWrite(SeleniumQueryFunctions.java:59)
        at io.github.seleniumquery.internal.SqObject.val(SqObject.java:164)
    

    This is the html code for the iFrame: screen shot 2016-06-29 at 16 07 24

    Any idea of what is happening? I tried different element values but one of them is $(//*[@id='CQrte']/p).val("test") and before executing this line I changed to the correct iframe

    subsystem:functions scope:impact-user 
    opened by jordiponsllaurado 6
  • Enable attribute quoting flexibility

    Enable attribute quoting flexibility

    Currently, we require quoting.

    We should allow selectors such as "a[href*=#]", "input[data-pos=\\:first]", "[num=1]", "[num=-1]", [attr=123] and alike.

    subsystem:selector 
    opened by acdcjunior 6
  • SeleniumQuery considers good an invalid url after correct url

    SeleniumQuery considers good an invalid url after correct url

    I'm currently testing with seleniumQuery and Firefox 38.7 a test that checks for an invalid URL, then for a valid one, then for an invalid one, as it follows:

    browser.get("InvalidURL");
    browser.get(validURL);
    browser.get("invalidURL");
    

    The first one throws an WebDriverException: Target URL InvalidURL is not well-formed. which is expected. The second one opens the validURL as expected. But the third one, instead of trying to open "InvalidURL", i opens "www.invalidurl.com", which is a valid URL, making the test to fail.

    Any chance on how to fix that?

    Thanks.

    opened by ghost 5
  • How to use EventFiringWebDriver

    How to use EventFiringWebDriver

    How can I attach EventFiringWebDriver to the webdriver. EventFiringWebDriver is used to listen to the events in the browserdriver. It is a wrapper over the webdriver initited as below

    EventFiringWebDriver efwd = new EventFiringWebDriver(ie11); efwd.register(new CustomEventLogger());

    How can I get the efwd when i access the driver using $.driver().get()

    Thanks

    subsystem:browser builder 
    opened by gmkumar2005 4
  • [Question] multiple condicionals

    [Question] multiple condicionals

    Is there any way to check if some element has one condition or another one?

    For example If I have an element that has a text or a value attribute it would be possible to sendKeys to that element and wait until the value or the text are the expected ones, something like $(element).val(text).waitUntil().text().isEqualTo(text).or().val().isEqualTo(text)

    opened by jordiponsllaurado 4
  • StaleElementException after clicking an element

    StaleElementException after clicking an element

    After clicking on some button, the element is already clicked, but the method throws a StaleElementException. This is reproducible on only some buttons in the page, but not on all of them.

    I use a css selector that is unique in order to ensure that I click on the correct button.

    The curious thing is that the Exception is thrown AFTER clicking the button, so the element is actually used.

    This is the Stacktrace:

    Caused by: org.openqa.selenium.StaleElementReferenceException: Element not found in the cache - perhaps the page has changed since it was looked up
    For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
    Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
    System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11', java.version: '1.8.0_72'
    Driver info: driver.version: unknown
    Command duration or timeout: 3.43 seconds
    For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
    Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06'
    System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11', java.version: '1.8.0_72'
    Driver info: org.openqa.selenium.remote.RemoteWebDriver
    Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=38.4.0, platform=MAC, nativeEvents=false, acceptSslCerts=true, webdriver.remote.sessionid=b76c649d-22d3-487a-8ba8-51a463afc67d, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
    Session ID: b76c649d-22d3-487a-8ba8-51a463afc67d
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
        at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:326)
        at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
        at io.github.seleniumquery.functions.jquery.events.ClickFunction.click(ClickFunction.java:47)
        at io.github.seleniumquery.SeleniumQueryObject.click(SeleniumQueryObject.java:321)
        at biz.netcentric.at.selcq.spi.tools.InteractionHelper.clickAndWait(InteractionHelper.java:34)
        at biz.netcentric.at.selcq.spi.tools.InteractionHelper.clickAndWait(InteractionHelper.java:30)
        at biz.netcentric.at.selcq.frontends.touchui.PageCreatorImpl.createPage(PageCreatorImpl.java:23)
        at biz.netcentric.at.selcq.frontends.touchui.Sites.createPage(Sites.java:77)
        at biz.netcentric.at.selcq.impl.WebsitesImpl.createPage(WebsitesImpl.java:60)
        at biz.netcentric.at.selcq.CreatePageTest.createPageWithParametersTest(CreatePageTest.java:48)
        ... 23 more
    Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
    Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06'
    System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11', java.version: '1.8.0_72'
    Driver info: driver.version: RemoteWebDriver
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:138)
        ... 34 more
    Caused by: org.openqa.selenium.StaleElementReferenceException: Element not found in the cache - perhaps the page has changed since it was looked up
    For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
    Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
    System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11', java.version: '1.8.0_72'
    Driver info: driver.version: unknown
    For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
    Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06'
    System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11', java.version: '1.8.0_72'
    Driver info: driver.version: unknown
        at <anonymous class>.fxdriver.cache.getElementAt(resource://fxdriver/modules/web-element-cache.js:9351)
        at <anonymous class>.Utils.getElementAt(file:///var/folders/wf/94b1wttd0v1b6t0md1pkllp80000gn/T/anonymous2009414429332203653webdriver-profile/extensions/[email protected]/components/command-processor.js:8978)
        at <anonymous class>.fxdriver.preconditions.visible(file:///var/folders/wf/94b1wttd0v1b6t0md1pkllp80000gn/T/anonymous2009414429332203653webdriver-profile/extensions/[email protected]/components/command-processor.js:9979)
        at <anonymous class>.DelayedCommand.prototype.checkPreconditions_(file:///var/folders/wf/94b1wttd0v1b6t0md1pkllp80000gn/T/anonymous2009414429332203653webdriver-profile/extensions/[email protected]/components/command-processor.js:12517)
        at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///var/folders/wf/94b1wttd0v1b6t0md1pkllp80000gn/T/anonymous2009414429332203653webdriver-profile/extensions/[email protected]/components/command-processor.js:12534)
        at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///var/folders/wf/94b1wttd0v1b6t0md1pkllp80000gn/T/anonymous2009414429332203653webdriver-profile/extensions/[email protected]/components/command-processor.js:12539)
        at <anonymous class>.DelayedCommand.prototype.execute/<(file:///var/folders/wf/94b1wttd0v1b6t0md1pkllp80000gn/T/anonymous2009414429332203653webdriver-profile/extensions/[email protected]/components/command-processor.js:12481)
    
    opened by jordiponsllaurado 4
  • driver.switchTo.activeElement() throws ClassCast exception (IE 10 & 11 especially, 32 bit IEDriver)

    driver.switchTo.activeElement() throws ClassCast exception (IE 10 & 11 especially, 32 bit IEDriver)

    Summary Calls to driver.switchTo.activeELement() throws ClassCastExceptions

    Setup WebDriver Java Bindings 2.52.0 Affected Browsers: IE10 & 11 primarily (IEDriver 32 bit)

    * Steps to Reproduce* Attempts to switch to a modal using the call "driver.switchTo().activeElement();" throws the ClassCast Exception. Code snippet ...:

    clickElement(driver, xButton); // which is really a call to driver.findElement(By) wrapped with a WebDriverWait driver.switchTo().activeElement();

    Actual Results After the call to switch to the modal, we get:

    java.lang.ClassCastException: com.google.common.collect.Maps$TransformedEntriesMap cannot be cast to org.openqa.selenium.WebElement at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.activeElement(RemoteWebDriver.java:1045) at com.automatedTesting.redesigned.pageObjects.NotesModal.closeNotesModal(NotesModal.java:87) at com.automatedTesting.redesigned.testcases.Notes_testAddAcknowledgeButtonPresence.assertAddAcknowledgeBtnAbsence(Notes_testAddAcknowledgeButtonPresence.java:72) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

    opened by irileydev 4
  • Compatibility with jBrowserDriver?

    Compatibility with jBrowserDriver?

    Firstly, great library!

    Is it possible to use seleniumQuery with jBrowserDriver?

    As per this issue, I can pass an instance of jBrowserDriver to $.driver().use(driver);(since jBD extends WebDriver) but all subsequent calls to $ result in a hang.

    opened by dhruvbhatia 3
Releases(0.20.0)
  • 0.20.0(Jan 2, 2019)

  • 0.19.0(May 3, 2018)

  • 0.18.0(Dec 16, 2017)

    Highlights

    Automatic (.exe) driver download! Automatic driver quit! Headless for Chrome and Firefox:

    $.driver()
        .useChrome()
        .headless() // configures chrome to be headless
        .autoDriverDownload() // automatically downloads and configures chromedriver.exe
        .autoQuitDriver(); // automatically quits the driver when the JVM shuts down
    

    Assertions: Created $().assertThat(). Any function that is available for .waitUntil() is also available for asserting:

    $("#resultStats").assertThat().text().containsIgnoreCase("seconds");
    

    Improved waiting: Dramatically improved $().waitUntil() inner-workings and error messages:

    $("#foo").waitUntil().size().isGreaterThan(5);
    
    // When failing, it will now show:
    //
    // Timeout while waiting for $("#foo").waitUntil().size().isGreaterThan(5).
    // 
    // expected: <size() to be greater than 5>
    // but: <last size() was 2>
    

    And much more. See below.


    Whats new?

    • Added functions:

      • $().refresh() - refreshes (requeries) the object, minimizingStaleElementException issues
      • $.title() - returns page title
      • $.eval(<javascript code>) - evaluates general JavaScript code
      • $().eval(<javascript code>) - evaluates general JavaScript code receiving current elements as argument
      • $().stream() - return a Java 8 Stream
      • $().map(<function>) - runs the function on every matched element
    • Driver builder:

      • Added automatic driver download (backed by webdrivermanager)
        • $.driver().useChrome().autoDriverDownload();
        • $.driver().useFirefox().autoDriverDownload();
        • $.driver().usePhantomJS().autoDriverDownload();
        • $.driver().useInternetExplorer().autoDriverDownload();
      • Added Edge and Opera drivers support:
        • $.driver().useEdge().autoDriverDownload();
        • $.driver().useOpera().autoDriverDownload();
      • Added headless from Chrome and Firefox:
        • $.driver().useChrome().headless();
        • $.driver().useFirefox().headless();
    • Added auto-quit for every driver. Full examples:

      • $.driver().useChrome().headless().autoDriverDownload().autoDriverQuit();
      • $.driver().useFirefox().headless().autoDriverDownload().autoDriverQuit();
    • Wait system

      • dramatically improved wait system:
      • allowing greater chaining of expression
      • WAY more clear error messages
    • Assertion functions

      • Added $("#myDiv").assertThat().text().contains("abc");
    • .waitUntil() and .assertThat()

      • Added .matches(<Hamcrest Matcher>):
        • $("#myDiv").waitUntil().text().matches(Matchers.containsString("John"))
      • .matches(Pattern)
      • .matches(lambda predicate)
        • $("#ipt").waitUntil().val().matches(value -> value.length() > 50)
      • .isEmpty()
      • .isNotEmpty()
      • .isPresent()
      • .isVisible()
      • .isDisplayed()
      • .isHidden()
      • .isNotVisible()

    Dependencies:

    • Updated Selenium to 3.8.1 and more...

    Many more, check 0.18.0 milestone: https://github.com/seleniumQuery/seleniumQuery/milestone/15?closed=1

    Go get it:

    <dependency>
        <groupId>io.github.seleniumquery</groupId>
        <artifactId>seleniumquery</artifactId>
        <version>0.18.0</version>
    </dependency>
    
    Source code(tar.gz)
    Source code(zip)
  • 0.17.0(Dec 3, 2017)

    Noteworthy:

    • Updated to Selenium 3.8.0 (jdk8)

    • Updated htmlunit-driver to 2.27

    • Added Chrome headless mode:

      $.driver().useChrome().withHeadlessMode();
      

    Other changes

    • Created SeleniumQuery.seleniumQueryBrowser() to get the SeleniumQueryBrowser instance used by the global SeleniumQuery.$ field.
    • Update some dependencies, such as commons-lang3 from 3.5 to 3.6, as well as added commons-text 1.1.
    • Removed htmlunit's $.driver().useHtmlUnit().emulatingInternetExplorer8(), $.driver().useHtmlUnit().emulatingInternetExplorer11() and other browsers HtmlUnit does not emulate anymore.
    • Removed $.browser.function()s
      • The new place for the functions that were in $.browser.FUNCTION is either $.FUNCTION or $.driver().FUNCTION.
      • In other words, the function $.browser.function() will either be $.function() or $.driver().function().
    • Removed BrowserFunctionsWithDeprecatedFunctions (class that held that attribute while it was deprecated)
    Source code(tar.gz)
    Source code(zip)
  • 0.16.0(Jul 7, 2016)

    Noteworthy changes:

    • Updated Selenium to 2.53.1
    • Tweaked .val()'s behavior on non-editable elements:
      • Warning is no longer issued.
      • It attempts to clear element, if not possible, it no longer throws exception (in other words, the clearing is a best-effort operation).
      • Even if clearing did not work, it stills types the keys. If the driver throws an exception here, it is not suppressed.

    See the full list of changes here.

    Source code(tar.gz)
    Source code(zip)
  • 0.15.0(Apr 5, 2016)

  • 0.14.0(Mar 24, 2016)

  • 0.13.0(Feb 9, 2016)

    Noteworthy changes:

    • Added $().each(<function>).
    • Updated selenium to 2.51.0.
    • Improved error messages for $().waitUntil().text().isLessThan(<number>).
    • BUG FIX: a + b selector was behaving like a ~ b (direct adjacent was behaving like general adjacent).
      • If your code breaks due to this, then change your selector from + to ~.

    See the full list of changes here.

    Source code(tar.gz)
    Source code(zip)
  • 0.12.0(Jan 31, 2016)

  • 0.11.0(Jan 30, 2016)

    Noteworthy changes:

    • Added $("selector").filter("selector") and $("selector").filter(Predicate<WebElement> {...}) functions
    • Updated to Selenium 2.50.1
    • PhantomJS executable is now found more effectively on all OSes
    • Fixed a bug for :nth-child(n+b) (when no a was specified)
    • Updated other dependent-on libs' versions

    See the full list of changes here.

    Source code(tar.gz)
    Source code(zip)
  • 0.10.0(Dec 26, 2015)

    • Updated requirement to JDK 1.7 (due to selenium-java)
    • Updated Selenium version to 2.48.2
    • Changed PhantomJS dependency to 1.2.1.
    • .click() will throw exception if no element is clicked (see #89)
    • Using #id selector will use Selenium's By.id() and bring only one element (as Sizzle does - see #29)
    • $.driver().useHtmlUnit().emulatingInternetExplorer9(); removed (HtmlUnit does not emulate IE9 anymore);
    • $.driver().useHtmlUnit().emulatingFirefox(); now emulates FF38.
    • Changed the way we disable JavaScript at FirefoxDriver (due to inability to ask for it at the profile)

    Relevant issues: https://github.com/seleniumQuery/seleniumQuery/issues?utf8=%E2%9C%93&q=milestone%3A0.10.0+label%3Ascope%3Aexternal

    Source code(tar.gz)
    Source code(zip)
  • 0.9.0(Dec 2, 2014)

    This is the first version released to Maven Central.

    Contains most useful jQuery functions, as well as most CSS3 and jQuery/Sizzle extension selectors.

    Includes:

    • The $.driver().use* driver builder system
    • Several .waitUntil() functions
    • Initial plugin .as() functions

    All integration tests (about 3.5k tests over 2h40m) were be run against HtmlUnit (JS ON and OFF), Chrome, Firefox (JS ON and OFF), PhantomJS and IE 11.

    Get it through:

    <dependency>
        <groupId>io.github.seleniumquery</groupId>
        <artifactId>seleniumquery</artifactId>
        <version>0.9.0</version>
    </dependency>
    
    Source code(tar.gz)
    Source code(zip)
  • 0.8.5-b4xpath(Aug 28, 2014)

    There are minor errors in this current baseline, but the merge of the XPath system is really needed right now, so I'm creating this tag right now in order to mark a rollback point if ever needed.

    Source code(tar.gz)
    Source code(zip)
  • 0.8.0(Jun 6, 2014)

    Most useful jQuery functions sizzle/jQuery selectors are supported.

    Next steps are:

    • Remove old .waitUntil() code to simplify the function stack call (so debugging is clearer);
    • Possibly rework CSS selector system into a CSS to XPath compiler, as some selectors (such as :contains() when used alone demand too much work and can be slow).
    Source code(tar.gz)
    Source code(zip)
  • 0.7.0(May 19, 2014)

  • 0.6.2(May 14, 2014)

  • 0.6.0(Apr 22, 2014)

  • 0.5.0(Apr 20, 2014)

    This version's mark is the last snapshot where the .is() function requeries the DOM to test for the elements properties.

    Next version is applying a CSS Parser to parse the selector sent to .is().

    A big improvement in performance is expected, specially in pages with large DOMs (aka big number of elements).

    Source code(tar.gz)
    Source code(zip)
  • 0.4.0-RC3(Apr 9, 2014)

  • 0.4.0-RC2(Apr 7, 2014)

  • 0.4.0-RC1(Apr 5, 2014)

An implementation of darcy-web that uses Selenium WebDriver as the automation library backend.

darcy-webdriver An implementation of darcy-ui and darcy-web that uses Selenium WebDriver as the automation library backend. maven <dependency> <gr

darcy framework 20 Aug 22, 2020
This is public repository for Selenium Learners at TestLeaf

Selenium WebDriver Course for March 2021 Online Learners This is public repository for Selenium Learners at TestLeaf. Week1 - Core Java Basics How Jav

TestLeaf 86 Dec 29, 2022
Spark-Crawler: Apache Nutch-like crawler that runs on Apache Spark.

Sparkler A web crawler is a bot program that fetches resources from the web for the sake of building applications like search engines, knowledge bases

USC Information Retrieval & Data Science 396 Dec 17, 2022
Open Source Web Crawler for Java

crawler4j crawler4j is an open source web crawler for Java which provides a simple interface for crawling the Web. Using it, you can setup a multi-thr

Yasser Ganjisaffar 4.3k Jan 3, 2023
A scalable web crawler framework for Java.

Readme in Chinese A scalable crawler framework. It covers the whole lifecycle of crawler: downloading, url management, content extraction and persiste

Yihua Huang 10.7k Jan 5, 2023
Concise UI Tests with Java!

Selenide = UI Testing Framework powered by Selenium WebDriver What is Selenide? Selenide is a framework for writing easy-to-read and easy-to-maintain

Selenide 1.6k Jan 4, 2023
jsoup: the Java HTML parser, built for HTML editing, cleaning, scraping, and XSS safety.

jsoup: Java HTML Parser jsoup is a Java library for working with real-world HTML. It provides a very convenient API for fetching URLs and extracting a

Jonathan Hedley 9.9k Jan 4, 2023
Elegant parsing in Java and Scala - lightweight, easy-to-use, powerful.

Please see https://repo1.maven.org/maven2/org/parboiled/ for download access to the artifacts https://github.com/sirthias/parboiled/wiki for all docum

Mathias 1.2k Dec 21, 2022
A pure-Java Markdown processor based on a parboiled PEG parser supporting a number of extensions

:>>> DEPRECATION NOTE <<<: Although still one of the most popular Markdown parsing libraries for the JVM, pegdown has reached its end of life. The pro

Mathias 1.3k Nov 24, 2022
My solution in Java for Advent of Code 2021.

advent-of-code-2021 My solution in Java for Advent of Code 2021. What is Advent of Code? Advent of Code (AoC) is an Advent calendar of small programmi

Phil Träger 3 Dec 2, 2021
Dicas , códigos e soluções para projetos desenvolvidos na linguagem Java

Digytal Code - Programação, Pesquisa e Educação www.digytal.com.br (11) 95894-0362 Autores Gleyson Sampaio Repositório repleto de desafios, componente

Digytal Code 13 Apr 15, 2022
An EFX translator written in Java.

This is an EFX translator written in Java. It supports multiple target languages. It includes an EFX expression translator to XPath. It is used to in the generation of the Schematron rules in the eForms SDK.

TED & EU Public Procurement 5 Oct 14, 2022
Automated driver management for Selenium WebDriver

WebDriverManager is a library which allows to automate the management of the drivers (e.g. chromedriver, geckodriver, etc.) required by Selenium WebDr

Boni García 2.2k Dec 30, 2022
Ghost Driver is an implementation of the Remote WebDriver Wire protocol, using PhantomJS as back-end

Ghost Driver is an implementation of the Remote WebDriver Wire protocol, using PhantomJS as back-end

Ivan De Marino 1.9k Dec 15, 2022
Ready-to-use UI Test Automation Architecture using Java and Selenium WebDriver.

Selenium Test Automation Boilerplate Ready-to-use UI Test Automation Architecture using Java and Selenium WebDriver. Languages and Frameworks The proj

Tahanima Chowdhury 133 Dec 26, 2022
Java Deferred/Promise library similar to JQuery.

JDeferred 2.x JDeferred is a Java Deferred/Promise library similar to JQuery's Deferred Object. Inspired by JQuery and Android Deferred Object. If you

JDeferred 1.5k Dec 29, 2022
An implementation of darcy-web that uses Selenium WebDriver as the automation library backend.

darcy-webdriver An implementation of darcy-ui and darcy-web that uses Selenium WebDriver as the automation library backend. maven <dependency> <gr

darcy framework 20 Aug 22, 2020
A collection of bite size examples for using chrome DevTools protocol commands with Selenium Webdriver v4.

selenium-devtools-guide A collection of bite size examples for using chrome DevTools protocol commands with Selenium Webdriver v4. Chrome Devtools Pro

Sudharsan Selvaraj 4 Aug 12, 2021
This repository contains example codes which will help you to know how to use selenium webdriver.

❓ What is this Repository about? This repo has example codes with Selenium 4 features. Websites used for testing are: automationpractice.com, saucedem

Mohammad Faisal Khatri 86 Dec 30, 2022
Selenium Webdriver: Page Object Model (POM) With Page Factory

Prepare Web Testing Instance or Environment Selenium Webdriver: Page Object Model (POM) With Page Factory Prerequisite software Download & Install JDK

Hiro Mia 14 Oct 18, 2022