TestNG和Selenium- IE无法启动独立线程 [英] TestNG and Selenium- IE fails to launch independent threads

查看:86
本文介绍了TestNG和Selenium- IE无法启动独立线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用TestNG和Selenium进行并行测试.这在Firefox和Chrome中效果很好,但在IE中却无法使用.我让Web驱动程序执行的步骤如下:

I'm using TestNG and Selenium to perform parallel tests. This works great in Firefox and Chrome, but breaks in IE. The steps I have the web driver executing are as follow:

  1. 使用来自testng.xml的参数(在下面找到)创建浏览器实例
  2. 从测试用户凭据池中选择一个可用用户
  3. 用户已登录
  4. 测试继续

当IE启动其实例时,所有实例都分配有相同的用户.此外,所有实例似乎都在争夺哪个焦点. (相反,在Firefox和Chrome浏览器中,所有实例都被适当分配了自己的用户,不会争夺焦点.)

When IE launches its instances, all of them are assigned the same user. Furthermore, all instances appear to fight over which one has focus. (Conversely, in Firefox and Chrome, all instances are appropriately assigned their own user and do not fight over focus.)

因为每个IE实例都使用相同的用户凭据,所以我进行了测试冲突,并且由于它们争夺哪个实例具有焦点,因此由于waitForElementPresent命令而导致了Selenium TimeoutExceptions.

Because each IE instance uses the same user credentials, I get testing collisions and because they fight over which instance has focus, I get Selenium TimeoutExceptions due to waitForElementPresent commands.

我的直觉是IE根本无法同时打开多个唯一实例.谁能证实我的怀疑或指导我如何解决这个问题?谢谢您的帮助!

My hunch is that IE is simply incapable of having multiple unique instances open concurrently. Can anyone either confirm my suspicion or direct me as to how I might remedy the issue? Thank you for your help!!

作为参考,这是我的testng.xml文件:

For reference, here is my testng.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="6" verbose="0" name="Command line suite" parallel="tests">

    <!-- IE Tests -->
    <test name="SourceBoxUIIe" preserve-order="true">
        <parameter name="browser" value="ie"/>
        <classes>
            <class name="org.familysearch.links.uitests.SourceBoxUITest"/>
        </classes>
    </test>
    <test name="EditPageIe" preserve-order="true">
        <parameter name="browser" value="ie"/>
        <classes>
            <class name="org.familysearch.links.uitests.EditPageUITest"/>
        </classes>
    </test>
    <test name="LinksGadgetPageIe" preserve-order="true">
        <parameter name="browser" value="ie"/>
        <classes>
            <class name="org.familysearch.links.uitests.LinksGadgetPageUITest"/>
        </classes>
    </test>
    <test name="AdminChangeLogIe" preserve-order="true">
        <parameter name="browser" value="ie"/>
        <classes>
            <class name="org.familysearch.links.uitests.AdminChangeLogPageUITest"/>
        </classes>
    </test>
    <test name="AttachedToPageIe" preserve-order="true">
        <parameter name="browser" value="ie"/>
        <classes>
            <class name="org.familysearch.links.uitests.AttachedToPageUITest"/>
        </classes>
    </test>
    <test name="ChangeLogIe" preserve-order="true">
        <parameter name="browser" value="ie"/>
        <classes>
            <class name="org.familysearch.links.uitests.ChangeLogUITest"/>
        </classes>
    </test>

    <!-- Firefox Tests Would Be here -->
    <!-- Chrome Tests Would Be Here-->

  <!-- Command line test -->
</suite> <!-- Command line suite -->

推荐答案

您的直觉几乎是正确的.根据 wiki :

Your hunch is almost correct. Per the wiki :

InternetExplorerDriver的多个实例

随着IEDriverServer.exe的创建,应该可以创建和使用InternetExplorerDriver的多个同时实例. 但是,此功能在很大程度上未经测试,并且cookie,窗口焦点等可能存在问题.如果尝试使用IE驱动程序的多个实例并遇到此类问题,请考虑使用RemoteWebDriver和虚拟机.

With the creation of the IEDriverServer.exe, it should be possible to create and use multiple simultaneous instances of the InternetExplorerDriver. However, this functionality is largely untested, and there may be issues with cookies, window focus, and the like. If you attempt to use multiple instances of the IE driver, and run into such issues, consider using the RemoteWebDriver and virtual machines.

在InternetExplorer的多个实例之间共享cookie(和另一个会话项)时,有2种解决方案.

There are 2 solutions for problem with cookies (and another session items) shared between multiple instances of InternetExplorer.

首先是在私有模式下启动InternetExplorer.之后,InternetExplorer将使用干净的会话数据启动,并且退出时不会保存更改的会话数据.为此,您需要向驱动程序传递2种特定功能:即具有真实值的forceCreateProcessApi和具有-private值的ie.browserCommandLineSwitches.请注意,它仅适用于InternetExplorer 8和更高版本,并且Windows注册表HKEY_CURRENT_USER \ Software \ Microsoft \ Internet Explorer \ Main路径应包含值为0的键TabProcGrowth.

The first is to start your InternetExplorer in private mode. After that InternetExplorer will be started with clean session data and will not save changed session data at quitting. To do so you need to pass 2 specific capabilities to driver: ie.forceCreateProcessApi with true value and ie.browserCommandLineSwitches with -private value. Be aware that it will work only for InternetExplorer 8 and newer, and Windows Registry HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main path should contain key TabProcGrowth with 0 value.

第二个是在InternetExplorer启动期间清理会话.为此,您需要将具有真实值的特定ie.ensureCleanSession功能传递给驱动程序.这将清除InternetExplorer所有正在运行的实例(包括手动启动的实例)的缓存.

The second is to clean session during InternetExplorer starting. For this you need to pass specific ie.ensureCleanSession capability with true value to driver. This clears the cache for all running instances of InternetExplorer, including those started manually.

这篇关于TestNG和Selenium- IE无法启动独立线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆