Selenium 2(WebDriver) or Geb?
I am very much impressed with web driver and page object pattern. Recently I sa开发者_StackOverfloww Geb framework and with spock framework combination seems to be like a powerful alternate option for automated tests. Is anyone one using Geb? Do you think of any limitations of Geb?
Using Geb at our workplace has been a life-saver. I can't imagine this many people (with absolutely no programming background) picking up Selenium in as short a time span.
I've been very successful creating mavenized geb projects that we have running on Jenkins for our CI. It does have a few limitations like not having the drag and drop ability right out of the box. However, you are always free to use the Selenium APIs whenever the need arises. Also, to the commenter about it lacking the support for phantomJS - says who? You can use absolutely any driver that selenium supports. Check this link for details.
There's nothing wrong with Geb from what I have experienced, but I would widen the search to include some of the recent(ish) drivers coming from Rubyland. Webrat was a great starter, but Capybara is actually quite excellent.
It takes more of a meta-approach, and provied a unified API for several different drivers, including Selenium and head-less alternatives such as HtmlUnit or env.js.
Thanks to JRuby, using libraries written in Ruby os now quite easy.
I have used Geb framework. It is groovy based automation framework. I had issues with creating common reusable methods and common page methods.
Geb runs WebDriver in Groovy. It looks pretty cool and make make WebDriver easier.
If you use WebDriver directly, you can pick from a number of languages.
Geb is great, the only thing lacking is the support of a modern headless driver like phantomJS. There is a project named Ghostdriver but it isn't ready yet. Overall, I am loving using Spock and Geb and it's a game changer on how we develop our web apps at work.
Ghostdriver is now available for Selenium lovers. Here's how you can use it with Geb.
Maven-
<dependency>
<groupId>com.github.detro.ghostdriver</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
GebConfig-
// your path to phantomjs binary
phantombinary = "/Users/kruttik.aggarwal/phantomjs-1.9.7-macosx/bin/phantomjs"
driver = {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
phantombinary
);
// Launch driver (will take care and ownership of the phantomjs process)
WebDriver driver = new PhantomJSDriver(caps);
System.out.println("starting driver");
driver
}
You may also have a look at Selenide, which is a very concise wrapper over Selenium: https://stackoverflow.com/a/43202999/4717152
精彩评论