nodewebdriver.json
Код: Выделить всё
{
"capabilities": [
{
"browserName": "MicrosoftEdge",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"platform": "WINDOWS"
},
{
"browserName": "firefox",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"platform": "WINDOWS"
},
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"platform": "WINDOWS"
},
{
"browserName": "internet explorer",
"maxInstances": 1,
"seleniumProtocol": "WebDriver",
"platform": "WINDOWS"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "http://Администратор:7565@127.0.0.1:4444",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets": [],
"withoutServlets": [],
"custom": {}
}
Код: Выделить всё
java -Dwebdriver.edge.driver=msedgedriver.exe -jar ".\selenium-server-4.35.0.jar" hub
Код: Выделить всё
java -Dwebdriver.edge.driver=msedgedriver.exe -jar ".\selenium-server-4.35.0.jar" node --config ".\NodeWebDriver.json"
< /code>
Затем я попытался запустить автономный сервер Selenium с PHP, используя EXEC следующим образом.
вариант 1 < /em> < /p>
$hubCommand = 'C:\\Program Files\\Java\\jdk-24\\bin\\java.exe -jar "C:\\Users\\pnfst\\selenium-server-4.35.0.jar" hub 2>&1 &';
$nodeCommand = 'C:\\Program Files\\Java\\jdk-24\\bin\\java.exe -Dwebdriver.edge.driver=C:\\Users\\pnfst\\msedgedriver.exe -jar "C:\\Users\\pnfst\\selenium-server-4.35.0.jar" node --config "C:\\Users\\pnfst\\NodeWebDriver.json" 2>&1 &';
$hubResult = exec($hubCommand, $hubOutput, $hubResult_code); // start hab
$nodeResult = exec($nodeCommand, $nodeOutput, $nodeResult_code); // start node
Код: Выделить всё
$psHubCommand = 'Start-Process -FilePath "C:\\Program Files\\Java\\jdk-24\\bin\\java.exe" -ArgumentList "-jar", "selenium-server-4.35.0.jar", "hub" -WorkingDirectory "C:\\Users\\pnfst" -Verb RunAs';
$psNodeCommand = 'Start-Process -FilePath "C:\\Program Files\\Java\\jdk-24\\bin\\java.exe" -ArgumentList "-Dwebdriver.edge.driver=msedgedriver.exe", "-jar", "selenium-server-4.35.0.jar", "node", "--config", ".\\NodeWebDriver.json" -WorkingDirectory "C:\\Users\\pnfst" -Verb RunAs';
$hubCommand = "powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command " . escapeshellarg($psHubCommand) . " 2>&1 &";
$nodeCommand = "powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command " . escapeshellarg($psNodeCommand) . " 2>&1 &";
$hubResult = exec($hubCommand, $hubOutput, $hubResult_code); // start hab
$nodeResult = exec($nodeCommand, $nodeOutput, $nodeResult_code); // start node
$psHubCommand = 'Start-Process -FilePath "C:\\Windows\\system32\\cmd.exe" -ArgumentList "/c", "C:\\Users\\pnfst\\selenium-server-hub.bat" -WorkingDirectory "C:\\Users\\pnfst" -Verb RunAs';
$psNodeCommand = 'Start-Process -FilePath "C:\\Windows\\system32\\cmd.exe" -ArgumentList "/c", "C:\\Users\\pnfst\\selenium-server-node.bat" -WorkingDirectory "C:\\Users\\pnfst" -Verb RunAs';
$hubCommand = "powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command " . escapeshellarg($psHubCommand) . " 2>&1 &";
$nodeCommand = "powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command " . escapeshellarg($psNodeCommand) . " 2>&1 &";
$hubResult = exec($hubCommand, $hubOutput, $hubResult_code); // start hab
$nodeResult = exec($nodeCommand, $nodeOutput, $nodeResult_code); // start node
< /code>
Все варианты возвращают код результата 0 и не запускайте HAB и Node. Вариант 2 броски с помощью PowerShell MissingArgument (команда HUB) и исключения PositionParameterNotFound (команда узла).
Как правильно запустить автономный сервер селена с php? < /P>
Подробнее здесь: https://stackoverflow.com/questions/797 ... php-script
Мобильная версия