Wie starte ich Selenium Standalone Server mit einem PHP -Skript?Php

PHP-Programmierer chatten hier
Anonymous
 Wie starte ich Selenium Standalone Server mit einem PHP -Skript?

Post by Anonymous »

In meinem PHP-Skript verwende ich die Php-Webriver-Bibliothek mit Edge WebDriver, um Daten von einer Webseite zu erhalten, und muss den Selenium Standalone-Server aus dem Skript starten. Ich habe Selenium-server-4.35.0.jar, msedgedriver.exe und nodewebdriver.json zum aktuellen Benutzerverzeichnis C: \ Users \ pnfst kopiert und auch 2 Fledermausdateien zum Ausführen von HAB und zum Ausführen von Knoten erstellt: selenium-server-hub.bat und selenium-server-node.bat. />NodeWebdriver.json

Code: Select all

{
"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://Администратор:[email protected]:4444",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets": [],
"withoutServlets": [],
"custom": {}
}
SELENIUM-SERVER-HUB.BAT

Code: Select all

java -Dwebdriver.edge.driver=msedgedriver.exe -jar ".\selenium-server-4.35.0.jar" hub
Selenium-server-node.bat

Code: Select all

java -Dwebdriver.edge.driver=msedgedriver.exe -jar ".\selenium-server-4.35.0.jar" node --config ".\NodeWebDriver.json"
< /code>
Dann habe ich versucht, den Selenium Standalone-Server mit EXEC wie folgt zu starten.$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
Variante 2

Code: Select all

$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
Variante 3
$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>
Alle Varianten geben Ergebniscode 0 und starten Sie nicht HAB und Node. Variante 2 löst mit PowerShell MissingArgument (Hub -Befehl) und positionalparameternotfound (Knotenbefehl) Ausnahmen.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post