硒批判

发布于 2024-07-05 19:50:51 字数 639 浏览 6 评论 0 原文

我只是想从运行 Selenium 的人那里得到一些意见 (http://selenium.openqa.org) 我有对 WaTiN 有丰富的经验,甚至为其编写了一个录音套件。 我让它生成了一些结构良好的代码,但仅由我维护,看来我的公司几乎放弃了它。

如果您运行过 Selenium,您是否取得了很大的成功?

我将使用 .NET 3.5,Selenium 可以很好地配合它吗?

生成的代码是干净的还是只是所有交互的列表? (http:// /blogs.conchango.com/richardgriffin/archive/2006/11/14/Testing-Design-Pattern-for-using-WATiR_2F00_N.aspx

分布式测试套件的公平性如何?

对系统的任何其他抱怨或赞美将不胜感激!

I just wanted some opinions from people that have run Selenium (http://selenium.openqa.org) I have had a lot of experience with WaTiN and even wrote a recording suite for it. I had it producing some well-structured code but being only maintained by me it seems my company all but abandoned it.

If you have run selenium have you had a lot of success?

I will be using .NET 3.5, does Selenium work well with it?

Is the code produced clean or simply a list of all the interaction? (http://blogs.conchango.com/richardgriffin/archive/2006/11/14/Testing-Design-Pattern-for-using-WATiR_2F00_N.aspx)

How well does the distributed testing suite fair?

Any other gripes or compliments on the system would be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

水中月 2024-07-12 19:50:52

我从 Selenium IDE 和 Selenium Core 开始。 这些绝对是帮助您入门的好工具。 但它们并不是很强大,因为您只能使用 Selenese,Selenium 的基于 HTML 的逐个命令语言。

现在我将 Selenium Remote Control 与 Ruby 驱动程序结合使用,这使我能够利用 Ruby 提供的功能。 我测试了许多环境:Windows 2000、XP、Vista、Mac 10.4/10.5,对于每个适用的环境,Safari 2/3、Firefox 2/3、Internet Explorer 6/7。

Selenium 声称与所有这些操作系统和浏览器兼容,尽管我目前在使用 Internet Explorer 时遇到了问题(实际上,我在 StackOverflow 上的第一个问题就是关于这个问题)。 但我不知道有任何其他工具如此强大并且适用于如此多的平台。

我在使用 Selenium 时遇到的最大问题是 DOM 解析。 JavaScript 的 childNodes 不可靠,因为 Safari/Firefox 会忽略空格和空格。 注释节点,而 Internet Explorer 没有。 Internet Explorer 中的 XPath 比 SF/FF 中慢 10-20 倍。 innerHTML 在 IE 中并不总是可靠。

I started out with Selenium IDE and Selenium Core. Those are definitely good tools to get you started. But they're not very powerful, since you can only use Selenese, Selenium's HTML-based command-by-command language.

Now I use Selenium Remote Control with the Ruby driver, which allows me to utilize what Ruby offers. I test many environments: Windows 2000, XP, Vista, Mac 10.4/10.5, and for each of those that apply, Safari 2/3, Firefox 2/3, Internet Explorer 6/7.

Selenium claims to be compatible with all those OS's and browsers, though I'm having problems currently with Internet Explorer (my first question on StackOverflow is about that, actually). But I don't know of any other tools that are this powerful and works with so many platforms.

The biggest problem I've had with Selenium is the DOM parsing. JavaScript's childNodes is unreliable because Safari/Firefox ignore whitespace & comment nodes, while Internet Explorer doesn't. XPath in Internet Explorer is 10-20 times slower than in SF/FF. innerHTML isn't always reliable in IE.

迷乱花海 2024-07-12 19:50:52

我是 Selenium 的忠实粉丝。 不过,最好提前了解的一个主要问题是 Selenium IDE 在弹出窗口方面存在很多问题。 这些问题在 Selenium RC 中不会持续存在,但它会让开发变得有点头疼。

I'm a big fan of Selenium. One major gotcha that's good to know about ahead of time, though, is that Selenium IDE has a lot of trouble with pop-up windows. These problems don't persist in Selenium RC, but it can make development a bit of a headache.

兔姬 2024-07-12 19:50:52

Selenium 是相当不错的工具,但有几点需要注意:

  • Selenium IDE 和 Selenium 核心并不共享 100% 相同的功能。 例如,IDE 支持右键单击,但当前的核心版本不支持。 但是,使用其存储库中的较新版本可以解决这个问题。

  • 如果是 ext js、gwt 等,请确保您的显示元素拥有正确的 ID,而不是自动生成(随机)的 ID。

    如果是 ext js、gwt 等,

  • 维护测试用例。 我见过在 Selenium 测试和良好覆盖率上投入大量精力的案例。 后来测试开始失败,因为创建测试的人正忙于其他任务并且没有其他人愿意接触它们。 但这是管理问题,而不是 Selenium。

Selenium is pretty decent tool but there are couple things to watch out:

  • Selenium IDE and Selenium core do not share 100% same functionality. For example right clicking is supported by IDE but current core release does not have it. However, using a newer version from their repository solves that.

  • In case of ext js, gwt etc make sure you have proper IDs for your display elements instead of automatically generated (random) ones.

  • Maintaining test cases. I have seen cases where a lot of effort was put on Selenium tests and good coverage. Later on tests started to fail as the person creating them was busy with other tasks and no-one else wanted to touch them. But this was issue with management, not Selenium.

°如果伤别离去 2024-07-12 19:50:51

如果您使用 Selenium IDE 生成代码,那么您只需获取 selenium 执行的每个操作的列表将执行。 对我来说,Selenium IDE 是开始或进行快速“尝试和查看”测试的好方法。 但是,当您考虑可维护性和更具可读性的代码时,您必须编写自己的代码。

实现优秀 Selenium 代码的一个好方法是在代码表示导航流程的一种方式。 这是我在 Coding Dojo Floripa(来自巴西):

public class GoogleTest {

    private Selenium selenium;

    @Before
    public void setUp() throws Exception {
            selenium = new DefaultSelenium("localhost", 4444, "*firefox",
                            "http://www.google.com/webhp?hl=en");
            selenium.start();
    }

    @Test
    public void codingDojoShouldBeInFirstPageOfResults() {
            GoogleHomePage home = new GoogleHomePage(selenium);
            GoogleSearchResults searchResults = home.searchFor("coding dojo");
            String firstEntry = searchResults.getResult(0);
            assertEquals("Coding Dojo Wiki: FrontPage", firstEntry);
    }

    @After
    public void tearDown() throws Exception {
            selenium.stop();
    }

}


public class GoogleHomePage {

    private final Selenium selenium;

    public GoogleHomePage(Selenium selenium) {
            this.selenium = selenium;
            this.selenium.open("http://www.google.com/webhp?hl=en");
            if (!"Google".equals(selenium.getTitle())) {
                    throw new IllegalStateException("Not the Google Home Page");
            }
    }

    public GoogleSearchResults searchFor(String string) {
            selenium.type("q", string);
            selenium.click("btnG");
            selenium.waitForPageToLoad("5000");
            return new GoogleSearchResults(string, selenium);
    }
}

public class GoogleSearchResults {

    private final Selenium selenium;

    public GoogleSearchResults(String string, Selenium selenium) {
            this.selenium = selenium;
            if (!(string + " - Google Search").equals(selenium.getTitle())) {
                    throw new IllegalStateException(
                                    "This is not the Google Results Page");
            }
    }

    public String getResult(int i) {
            String nameXPath = "xpath=id('res')/div[1]/div[" + (i + 1) + "]/h2/a";
            return selenium.getText(nameXPath);
    }
}

希望有帮助

If you are using Selenium IDE to generate code, then you just get a list of every action that selenium will execute. To me, Selenium IDE is a good way to start or do a fast "try and see" test. But, when you think about maintainability and more readable code, you must write your own code.

A good way to achieve good selenium code is to use the Page Object Pattern in a way that the code represents your navigation flow. Here is a good example that I see in Coding Dojo Floripa (from Brazil):

public class GoogleTest {

    private Selenium selenium;

    @Before
    public void setUp() throws Exception {
            selenium = new DefaultSelenium("localhost", 4444, "*firefox",
                            "http://www.google.com/webhp?hl=en");
            selenium.start();
    }

    @Test
    public void codingDojoShouldBeInFirstPageOfResults() {
            GoogleHomePage home = new GoogleHomePage(selenium);
            GoogleSearchResults searchResults = home.searchFor("coding dojo");
            String firstEntry = searchResults.getResult(0);
            assertEquals("Coding Dojo Wiki: FrontPage", firstEntry);
    }

    @After
    public void tearDown() throws Exception {
            selenium.stop();
    }

}


public class GoogleHomePage {

    private final Selenium selenium;

    public GoogleHomePage(Selenium selenium) {
            this.selenium = selenium;
            this.selenium.open("http://www.google.com/webhp?hl=en");
            if (!"Google".equals(selenium.getTitle())) {
                    throw new IllegalStateException("Not the Google Home Page");
            }
    }

    public GoogleSearchResults searchFor(String string) {
            selenium.type("q", string);
            selenium.click("btnG");
            selenium.waitForPageToLoad("5000");
            return new GoogleSearchResults(string, selenium);
    }
}

public class GoogleSearchResults {

    private final Selenium selenium;

    public GoogleSearchResults(String string, Selenium selenium) {
            this.selenium = selenium;
            if (!(string + " - Google Search").equals(selenium.getTitle())) {
                    throw new IllegalStateException(
                                    "This is not the Google Results Page");
            }
    }

    public String getResult(int i) {
            String nameXPath = "xpath=id('res')/div[1]/div[" + (i + 1) + "]/h2/a";
            return selenium.getText(nameXPath);
    }
}

Hope that Helps

坐在坟头思考人生 2024-07-12 19:50:51

我正在使用 Selenium Remote Control 来测试 ASP.Net 应用程序(这也是我假设您的目标),并且效果很好。

如果您从未使用过 Selenium,请观看一些 使用 Selenium IDE 的截屏视频。 这将使您很好地了解“Selenium”的工作原理。 IDE 是一个 Firefox 插件,基本上可以让您开发快速的录制和播放测试。 对于更大的测试套件或编写真正可维护的测试,我建议使用 Selenium Remote Control。 (如果您刚刚开始使用,那么 IDE 非常棒。)

Selenium Remote Control 让您可以使用您最喜欢的语言和单元测试框架来驱动 Web 浏览器以执行您的测试。 如果您最熟悉 C#/NUnit,则可以以这种方式编写测试并使用您喜欢的所有 NUnit 功能。 (例如,Test-Driven.net 插件)。 此外,由于您的测试是用高级语言编写的,因此您可以执行诸如从特定测试类继承之类的操作,您可以使用该测试类使实际测试方法代码更加清晰。 (或者至少这就是我编写测试的方式。它让我可以测试复杂的场景,从而使我的测试方法行数保持在合理的数量。)

您提到了分布式测试。 不幸的是,我还没有找到一种方法来将 Selenium Grid 项目与 NUnit 一起使用。 Selenium Grid 允许您在许多不同的机器和浏览器实例上执行测试套件。 因此,您可以将负载分散到一台或多台计算机上的四个 Grid 实例上(即一次在四个不同的浏览器实例中运行),而不是依次运行 200 个测试方法(即串行)。关于您想要获得的分布程度。

如果您使用 Java 或 PHP 编写测试,您可能会有更好的运气。 我期望这可以通过 NUnit 随 NUnit2.5 版本提供,其中将包括用于并行测试的 pNUnit。

如果您对硒有任何其他疑问,只需澄清您原来的问题,我将很乐意尝试帮助您。 (Selenium 只是我每天使用的工具之一,所以我喜欢帮助新人开始使用它......)

I'm using Selenium Remote Control in order to test ASP.Net apps (which is what I'm assuming you'll be targetting as well), and it works great.

If you've never used Selenium, watch some of the screencasts for using Selenium IDE. This will give you a good idea of how 'Selenium' works. The IDE is a firefox plugin that basically lets you develop quick record-and-play tests as you go. For larger test suites or for writing really maintainable tests though, I'd recommend Selenium Remote Control. (The IDE is terrific if you're just getting a start though.)

Selenium Remote Control lets you use your favourite language and unit testing framework to drive a web browser in order to execute your tests. If you're most comfortable with C#/NUnit, you can write your tests that way and use all the NUnit goodies that you like. (For example, the Test-Driven.net plugin). Also, since your tests are written in a high level language, you're able to do things like inherit from a particular test class which you can use to make your actual test method code much cleaner. (Or at least thats the way I write my tests. It lets me test complex scenarios which keeping my test method line-count at a reasonable number.)

You mention distributed testing. Unfortunately I haven't found a way to use the Selenium Grid project with NUnit. Selenium Grid allows you to execute your test suite over a number different machines and browser instances. So rather than running through say 200 test methods one after another (ie, serially), you could spread the load out over say four Grid instances (ie, running in four different browsers instances at a time) on a single machine or multiple machines depending on how distributed you want to get.

If you write your tests in Java or PHP though, you might have better luck. I'm expecting this to be available via NUnit with the release of NUnit2.5 which will include pNUnit for parallel testing.

If you have any further questions about selenium, just clarify your original question and I'll be happy to try and help you out. (Selenium is just one of those tools that I use everyday so I enjoy helping to get new people started with it..)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文