java Selenium 2(WebDriver)还是Geb?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5999303/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 13:55:23  来源:igfitidea点击:

Selenium 2(WebDriver) or Geb?

javatestingseleniumautomationwebdriver

提问by Aravind Yarram

I am very much impressed with web driver and page object pattern. Recently I saw Gebframework 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?

我对 Web 驱动程序和页面对象模式印象深刻。最近看到Geb框架和 spock 框架的组合似乎是自动化测试的一个强大的替代选择。有人用geb吗?你认为Geb有什么限制吗?

采纳答案by testing123

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.

在我们的工作场所使用 Geb 可以挽救生命。我无法想象有这么多人(完全没有编程背景)在这么短的时间内学习 Selenium。

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 linkfor details.

我已经非常成功地创建了我们在 Jenkins 上为我们的 CI 运行的 mavenized geb 项目。它确实有一些限制,例如没有开箱即用的拖放功能。但是,只要需要,您始终可以自由使用 Selenium API。另外,对于关于它缺乏对 phantomJS 支持的评论者 - 说谁?您绝对可以使用 selenium 支持的任何驱动程序。查看此链接了解详情。

回答by P?l Brattberg

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. Webratwas a great starter, but Capybarais actually quite excellent.

从我的经历来看,Geb 没有任何问题,但我会扩大搜索范围以包括一些来自 Rubyland 的最近(ish)驱动程序。Webrat是一个很好的入门者,但Capybara实际上非常出色。

It takes more of a meta-approach, and provied a unified API for several different drivers, including Seleniumand head-less alternatives such as HtmlUnitor env.js.

它采用了更多的元方法,并为几个不同的驱动程序提供了统一的 API,包括Selenium和无头替代方案,如HtmlUnitenv.js

Thanks to JRuby, using libraries written in Ruby os now quite easy.

多亏了JRuby,现在使用用 Ruby 操作系统编写的库非常容易。

回答by Prabu

I have used Geb framework. It is groovy based automation framework. I had issues with creating common reusable methods and common page methods.

我用过 Geb 框架。它是基于 groovy 的自动化框架。我在创建通用的可重用方法和通用页面方法时遇到了问题。

回答by Precipitous

Geb runs WebDriver in Groovy. It looks pretty cool and make make WebDriver easier.

Geb 在 Groovy 中运行 WebDriver。它看起来很酷,使 WebDriver 更容易。

If you use WebDriver directly, you can pick from a numberof languages.

如果你直接使用webdriver的,可以从挑选语言

回答by ontk

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.

Geb 很棒,唯一缺乏的是像 phantomJS 这样的现代无头驱动程序的支持。有一个名为 Ghostdriver 的项目,但它还没有准备好。总的来说,我喜欢使用 Spock 和 Geb,它改变了我们在工作中开发 Web 应用程序的方式。

回答by Kruttik

Ghostdriver is now available for Selenium lovers. Here's how you can use it with Geb.

Ghostdriver 现在可供 Selenium 爱好者使用。以下是如何将它与 Geb 一起使用。

Maven-

马文-

<dependency>
    <groupId>com.github.detro.ghostdriver</groupId>
    <artifactId>phantomjsdriver</artifactId>
    <version>1.1.0</version>
    <scope>test</scope>
</dependency>

GebConfig-

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
}

回答by Andreas M. Oberheim

You may also have a look at Selenide, which is a very concise wrapper over Selenium: https://stackoverflow.com/a/43202999/4717152

你也可以看看 Selenide,它是一个非常简洁的 Selenium 包装器:https: //stackoverflow.com/a/43202999/4717152