我正在尝试以编程方式创建临时firefox配置文件,以便在selenium grid2的selenium测试中使用。
下面是我目前正在运行的代码。
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName("firefox");
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference(PREFERENCE_NAME,userAgent.getUserAgentString());
capabilities.setCapability(FirefoxDriver.PROFILE,profile);
RemoteWebDriver driver = new RemoteWebDriver(url, capabilities);如果与配置文件有关的所有行都被注释掉,此代码将运行。然而,实际上,它将导致此异常。
Caused by: org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities [{browserName=firefox, version=, platform=ANY, firefox_profile=UEsDBBQACAgIAFxzBEkAAAAAAAAAA...}]我了解到,例外情况是它无法在selenium服务器上找到匹配的功能设置。但是,它应该转移配置文件,而不是寻找匹配的配置文件。"firefox_profile=“后面的字符串是"profile.toJson()”的输出,因此似乎在某种程度上它做的事情是正确的。我只是不明白为什么服务器不接受它。
这里是我的selenium服务器启动脚本
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=6565 -cp selenium-server-standalone-2.53.0.jar org.openqa.grid.selenium.GridLauncher -role node -nodeConfig nodeconfig.json -hub http://192.168.5.151:4444/grid/register和节点配置文件。
{
"capabilities": [
{
"browserName": "firefox",
"nativeEvents": true,
"acceptSslCerts": true,
"javascriptEnabled": true,
"takesScreenshot": true,
"firefox_profile": "selenium",
"version": "44.0",
"platform": "WIN10",
"maxInstances": 1,
"firefox_binary": "C:\\Program Files\\Mozilla\ Firefox\\firefox.exe",
"cleanSession": true,
"file.download.supported": true,
"file.download.watcher": "WindowsFirefoxDownloadWatcher",
"file.download.directory": "C:\\Users\\IEUser\\Downloads"
},
{
"browserName": "chrome",
"nativeEvents": true,
"maxInstances": 1,
"platform": "WIN10",
"webdriver.chrome.driver": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
},
{
"browserName": "MicrosoftEdge",
"nativeEvents": true,
"maxInstances": 1,
"platform": "WIN10"
}
],
"configuration":
{
"_comment" : "Windows 10 with file download support",
"cleanUpCycle": 2000,
"timeout": 0,
"port": 5555,
"host": ip,
"register": true,
"hubPort": 4444,
"maxSessions": 1,
"Dwebdriver.edge.driver=C:\\Program Files (x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe": ""
}
}我对此进行了大量的研究,但没有发现任何类似问题的人。我能够通过直接在vm上创建概要文件并在启动脚本中指定它来选择它。然而,这不是我想要的功能。
任何帮助都将不胜感激!谢谢!
发布于 2016-08-05 13:46:26
转发新会话错误找不到:功能[{browserName=firefox,version=,platform=ANY,
这基本上是网格告诉您的方式,您请求网格分配一个可以运行firefox的节点(不管平台风格或版本号如何),但是网格没有任何这样的节点可供其使用(在节点配置JSON文件中,您已经指定键firefox_profile的值应为"Selenium“。
"firefox_profile":"selenium“
不确定为什么要在JSON配置文件中设置这个键。
我了解到,例外情况是它无法在selenium服务器上找到匹配的功能设置。但是,它应该转移配置文件,而不是寻找匹配的配置文件。
只有在找到与请求的功能匹配的节点时,Grid才会这样做。在您的示例中,Grid无法找到任何与您请求的任何节点匹配的节点,因此配置文件将不会被传输(因为此时目的地未知)。
因此,您需要去掉您的firefox_profile JSON文件中的键“node_config”才能正常工作。然后,firefox配置文件将被转发到该特定节点,并且您的执行将开始使用您创建的firefox配置文件。
https://stackoverflow.com/questions/38776028
复制相似问题