多个Selenium本地端口问题

0 投票
1 回答
579 浏览
提问于 2025-04-17 05:36

我的简单需求:

我想在本地的两个不同Selenium端口上打开两个IE浏览器。

我的设置

我的Selenium服务器设置

Selenium服务器(版本2.2.0)在Windows 7上运行,使用的端口是4444和4445。

我的Selenium客户端设置

Selenium客户端 - 在同一台运行Selenium服务器的Windows 7上使用Python 2.7的Selenium RC。

我的代码可以在两个不同的Selenium端口上打开两个浏览器,代码如下:

# C:\Python27\python.exe
from selenium import selenium
def localhost_issue():
    '''
    This method will simply open two IE browsers on two different Selenium
    ports on localhost

    This FAILS to happens because only one browser opens at the end

    '''
    myserver = 'localhost'

    s1 = selenium(myserver, 4444, '*iexplore', 'http://www.google.com/')
    s1.start()
    s1.open('/')

    s2 = selenium(myserver, 4445, '*iexplore', 'http://www.msn.com/')
    s2.start()
    s2.open('/')    # FAILS BECAUSE browser 1 is overwritten by browser 2
localhost_issue()

这个问题只出现在IE浏览器上(而不是Firefox)。有没有人能帮帮我?

谢谢,
Amit

1 个回答

0

我不想带来坏消息,但这是因为Firefox是基于用户配置文件来工作的,而IE(Internet Explorer)则是另一种情况。虽然这和Selenium Grid有关,但同样适用于你的问题。你可以查看这个链接了解更多信息:http://svn.openqa.org/fisheye/browse/~raw,r=390/selenium-grid/website/src/main/webapp/faq.html#i_get_some_strange_errors_when_i_run_multiple_internet_explorer_instances_on_the_same_machine

撰写回答