我在用 Selenium2 测试 IE6 时遇到了这个问题。我使用 Perl 绑定(Selenium::Remote::Driver),但我将非常感谢任何建议,即使它们来自对 Selenium for Java 等有经验的人。
问题是当我尝试这样做时:
my %opt = (
browser_name => 'internet explorer',
version => '6',
platform => 'WINDOWS',
proxy => {
proxyType => 'direct',
}
);
my $driver = Selenium::Remote::Driver->new(%opt);
$driver->get('http://www.google.com');
my $elem = $driver->find_element('gs_htif0', 'id');
$elem->send_keys('fooooooo');
浏览器打开,但随后测试因消息An element could not be located on the page using the given search parameters: gs_htif0,id at ...
而终止,而在 IE7 中一切正常,并且 IE 驱动程序的文档说 IE6 已经过测试
之后,我尝试使用 启动一个节点"seleniumProtocol": "Selenium"
,我认为这是测试没有驱动程序的任何浏览器的选项,因此可以以旧的“JavaScript 仿真”用户操作方式进行测试,但后来浏览器没有从头开始,测试因消息而死java.lang.NullPointerException: sessionId should not be null; has this session been started yet?
我的集线器配置是:
{
"host": null,
"port": 4444,
"newSessionWaitTimeout": -1,
"servlets" : [],
"prioritizer": null,
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"nodePolling": 5000,
"cleanUpCycle": 5000,
"timeout": 300000,
"browserTimeout": 0,
"maxSession": 5
}
我的节点配置是:
{
"capabilities":
[
{
"platform": "WINDOWS",
"browserName": "internet explorer",
"version": "6",
"seleniumProtocol": "WebDriver",
"ensureCleanSession": true
}
],
"configuration":
{
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 1,
"port": 5555,
"host": "192.168.1.6",
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": "192.168.1.34"
}
}
启动节点命令是java -jar selenium-server-standalone-2.29.0.jar -role node -nodeConfig node_ie6_conf.json -Dwebdriver.ie.driver="IEDriverServer_2.29x32.exe" > nul
启动集线器命令是java -jar selenium-server-standalone-2.29.0.jar -role hub -hubConfig hub_conf.json &> dev/null
任何人都可以帮助我吗?我的赞赏。
更新 对于我问题的第二部分,我认为 Selenium::Remote::Driver 仅适用于 webDriver 协议,但我不确定