我之前曾问过Session not created Selenium/webdriver when using Safari 12
我已经添加了selenium-server-4.0.0-alpha-1.jar,但仍然出现相同的错误
browserUnderTest = new webdriver.Builder()
.usingServer( new safari.ServiceBuilder().addArguments('--legacy').build().start())
.forBrowser('safari')
.build();
结果
SessionNotCreatedError: Request body does not contain required parameter 'capabilities'.
at Object.throwDecodedError (/Users/learnincurv/Desktop/MyTestFramework/node_modules/selenium-webdriver/lib/error.js:514:15)
at parseHttpResponse (/Users/learnincurv/Desktop/MyTestFramework/node_modules/selenium-webdriver/lib/http.js:519:13)
at /Users/learnincurv/Desktop/MyTestFramework/node_modules/selenium-webdriver/lib/http.js:441:30
at processTicksAndRejections (internal/process/task_queues.js:85:5)
From: Task: WebDriver.createSession()
at Function.createSession (/Users/learnincurv/Desktop/MyTestFramework/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at createDriver (/Users/learnincurv/Desktop/MyTestFramework/node_modules/selenium-webdriver/index.js:170:33)
at Builder.build (/Users/learnincurv/Desktop/MyTestFramework/node_modules/selenium-webdriver/index.js:635:14)
at Object.<anonymous> (/Users/learnincurv/Desktop/MyTestFramework/OUR_autotest.js:353:6)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
at internal/main/run_main_module.js:17:11 {
name: 'SessionNotCreatedError',
remoteStacktrace: ''
}
我没有看到任何人成功完成此操作的证据,我希望有人指出如何在没有硒网格的情况下运行它。
答案 0 :(得分:0)
只是重新发现了一种显而易见的解决方法,即在另一个终端中分别启动硒。
async function f() {
startSelenium('open -a Terminal.app startSeleniumForSafari.sh');
driver = new webdriver.Builder()
.forBrowser('safari')
.usingServer('http://localhost:4444/wd/hub')
.build();
}
f();
Shell脚本仅仅是:
echo "Starting Selenium"
java -jar selenium-server-4.0.0-alpha-1.jar -port 4444
echo "Selenium Started"