Selenium Grid 中 IE6(和多个浏览器)的设置

发布于 2024-08-15 10:42:42 字数 330 浏览 5 评论 0原文

我很难掌握有关 selenium Grid/RC 的一些概念。我需要的是为测试提供特定的环境(ie6-on-xp、ie7-on-xp 等)。对于我一直在阅读的内容,grid_configuration.yml 中的浏览器行没有提及我使用的 MSIEFirefox 版本。我正在跑步。所以我不知道以哪种形式可以告诉 Grid/RC 我想要一些特定的浏览器以及运行它们的路径(RC 如何知道要运行哪个 exe?)

其次,我想运行便携式版本这些浏览器。我只在测试中看到了指定的内容,而没有在 RC 的命令行中看到运行它们的内容。每次测试就是这样做的吗?

I'm having a hard time trying to grasp some concepts on selenium Grid/RC. What I need is to provide specific environments (ie6-on-xp, ie7-on-xp, etc) to the tests. For what I've been reading, the browser line in grid_configuration.yml do not make any reference of what version of MSIE or Firefox I'm running. So I can't get my head around in which form I can tell Grid/RC that I want some specific browsers and the path to run them (how RC knows which exe to run?)

Second, I'd like to run portable versions of those browsers. I've only seen that specified in the tests, and not in the RC's command line to run them. That is the way to do it, per test?

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

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

发布评论

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

评论(2

一个人练习一个人 2024-08-22 10:42:42

我将通过分解您需要的信息来回答您的问题

我需要的是提供具体的
环境(ie6-on-xp、ie7-on-xp、
等)进行测试。

既然你不能在同一台机器上拥有多个 IE 实例,我知道有一些应用程序允许你这样做,但根据我的经验,它们造成的问题比解决问题更多。理想情况下,您希望不同的机器来运行测试。通过这样做,您还可以设置一个硒农场供您的开发人员使用,因为他们可以针对特定实例进行测试。因此,将网格设置为基础设施是一个很好的步骤。

对于我一直在读的内容来说,
grid_configuration.yml 中的浏览器行
不要提及任何内容
我的 MSIE 或 Firefox 版本
跑步。所以我无法思考
我可以以哪种形式告诉 Grid/RC
我想要一些特定的浏览器和
运行它们的路径(RC 如何知道哪个
exe要运行吗?)

YAML 只是让您知道网格可以处理什么。启动网格时,您需要确保传递类似的配置。像 Se:RC 一样思考 Se:GRID,只不过您不关心 RC 服务器在哪里,因为您与一个中心位置对话,该中心位置会为您解决其余问题。

如果您需要它针对特定项目运行测试,那么您将需要在测试设置中处理这个问题。有一个常见的误解,即所有测试在每个浏览器中运行都是相同的。如果您在测试中从不依赖 XPath 或 CSS 选择器,就会发生这种情况,因为浏览器处理此问题的方式总是略有不同,并且这些细微的差异可能会导致不稳定的测试,因此应始终避免。

指定使用哪个浏览器进行测试的一种方法是拥有一个中央配置文件。在 C# 中,这将使用具有每个浏览器集合的 app.config 并执行

Config

<Firefox>
 <addKey browserVersion='3.5.6' OS='WindowsXP'>
</Firefox>

Central Config Class 查找 1 个元素

 public class BoothElement : ConfigurationElement
    {
        [ConfigurationProperty("browserVersion", DefaultValue = "", IsKey = true, IsRequired = true)]
        public string browserVersion
        {
            get
            {
                return ((string)(base["browserVersion"]));
            }
            set
            {
                base["browserVersion"] = value;

            }
        }

Tests

selenium = new DefaultSelenium(HubPort, HubPort, browserVersion, SUTServer);
selenium.Open("/test.htm");
//Rest of the test

中的 内容python,您可以在包含在所有测试中的模块中创建一个数组

include.py

hubServer = 'hub'
hubPort = 5555
sut = 'http://serverUnderTest'
firefox = [hubServer,hubPort,"\*chrome",sut]
iexplore = [hubServer,hubPort,"\*iehta",sut]

test.py

sel = selenium(firefox)
sel.open("/test.html")
#rest of the test

当使用 Selenium Grid 时,请尝试将其更多地视为测试基础设施帮助框架,希望对您有更多帮助。

第二,我想运行便携式
这些浏览器的版本。我只有
看到测试中指定的,并且
不能在RC的命令行中运行
他们。这就是这样做的方法,每
测试?

我从未尝试过让 Selenium 在移动浏览器上工作,并且认为它不会很好地工作,但是对于目前处于 alpha 状态的 Selenium 2,Android 支持测试应用程序。

从评论中编辑

   - name:    "Firefox on OS X"
     browser: "*firefox"
   - name:    "Firefox on Linux"
     browser: "*firefox"
   - name:    "IE on Windows"
     browser: "*iehta"
   - name:    "Safari on OS X"
     browser: "*safari"

假设我们有上述设置,根据 YAML 文件,我们有许多不同的 *firefox 实例。因此,要在我们的测试中调用这些不同的命令,我们的浏览器设置命令将类似于

selenium.Start(hubHost, hubPort, "Firefox on Linux", "http://serverUnderTest");
selenium.Start(hubHost, hubPort, "Firefox on OS X", "http://serverUnderTest");

集线器会将其转换为 *firefox。我更喜欢为我的环境使用非常精细的名称,而不是通常的 *firefox,这样如果出现故障,可以更容易地发现它在哪里以及在哪个特定浏览器上。

I will answer your question by breaking up the info that you need

What I need is to provide specific
environments (ie6-on-xp, ie7-on-xp,
etc) to the tests.

Well since you can't have multiple IE instances on the same machine, I know there are apps that allow you to do that but in my experience they cause more issues than solving them. Ideally you want different machines to run the tests. By doing this you are also setting up a selenium farm for your devs to use because they can target a test at a specific instance. So setting up Grid as an Infrastructure is a good step.

For what I've been reading, the
browser line in grid_configuration.yml
do not make any reference of what
version of MSIE or Firefox I'm
running. So I can't get my head around
in which form I can tell Grid/RC that
I want some specific browsers and the
path to run them (how RC knows which
exe to run?)

The YAML just lets you know what the grid can handle. When starting up the grid you need to make sure that you pass in similar configurations. Think of Se:GRID like you would Se:RC except you don't care where the RC server is because you speak to a central place that works the rest out for you.

If you need it to run tests against a specific items then you will need to handle this in your test setup. There is a common misconception that all tests will run the same in every single browser. This will happen if you never rely on XPath or CSS selectors in your tests because browsers always handle this slightly differently and the slight differences can lead to flaky tests which should always be avoided.

One way to specify which browser to use for a test is to have a central configuration file. In C# this would be using the app.config that has a collection for each browser and doing

Config

<Firefox>
 <addKey browserVersion='3.5.6' OS='WindowsXP'>
</Firefox>

Central Config Class looking inside 1 element

 public class BoothElement : ConfigurationElement
    {
        [ConfigurationProperty("browserVersion", DefaultValue = "", IsKey = true, IsRequired = true)]
        public string browserVersion
        {
            get
            {
                return ((string)(base["browserVersion"]));
            }
            set
            {
                base["browserVersion"] = value;

            }
        }

Tests

selenium = new DefaultSelenium(HubPort, HubPort, browserVersion, SUTServer);
selenium.Open("/test.htm");
//Rest of the test

In python you could create an Array in a module that you include on all your tests

include.py

hubServer = 'hub'
hubPort = 5555
sut = 'http://serverUnderTest'
firefox = [hubServer,hubPort,"\*chrome",sut]
iexplore = [hubServer,hubPort,"\*iehta",sut]

test.py

sel = selenium(firefox)
sel.open("/test.html")
#rest of the test

When using Selenium Grid try thinking of it more as a test infrastructure help framework and hopefully that will help you a little more.

Second, I'd like to run portable
versions of those browsers. I've only
seen that specified in the tests, and
not in the RC's command line to run
them. That is the way to do it, per
test?

I have never tried to get Selenium to work on mobile browsers and don't think it would work to well, however with Selenium 2 which is currently in alpha there is android support for testing apps.

EDIT FROM COMMENT

   - name:    "Firefox on OS X"
     browser: "*firefox"
   - name:    "Firefox on Linux"
     browser: "*firefox"
   - name:    "IE on Windows"
     browser: "*iehta"
   - name:    "Safari on OS X"
     browser: "*safari"

So say we have the above setup, according to the YAML file we have a number of different *firefox instances. So to call those different ones in our tests our browser setup command would look like

selenium.Start(hubHost, hubPort, "Firefox on Linux", "http://serverUnderTest");
or selenium.Start(hubHost, hubPort, "Firefox on OS X", "http://serverUnderTest");

The hub will translate that into *firefox for you. I prefer having very granular names for my environment instead of the usual *firefox so that if there is a failure its easier to spot where it was and on which specific browser.

闻呓 2024-08-22 10:42:42

虚拟机对于在 Selenium Grid farm 中设置“廉价”的 mule 来说非常方便。

Virtual machines can be very handy for setting up "inexpensive" mules in the Selenium Grid farm.

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