Selenium - Chrome二进制文件被忽略

时间:2017-06-07 06:18:05

标签: selenium selenium-chromedriver chromium

我更喜欢使用旧版本的Selenium 2.53.1与旧版本的Chromium 52.0和chromedriver 2.24。我在Windows 7上运行了以下命令:

const express = require('express');
const router = express.Router();
const passport = require('passport');
const jwt = require('jsonwebtoken');
const User = require('../modules/user');

// Register
router.post('/register', (req, res, next) => {
  let newUser = new User({
    username: req.body.username,
    password: req.body.password
  });

  newUser.addUser(function(err, user) => {
    if(err){
      res.json({success: false, msg:'Failed to register user'});
    } else {
      res.json({success: true, msg:'User registered'});
    }
  });
});    

module.exports = router;

正如您所看到的,我尝试了很多尝试start java -jar selenium-server-standalone-2.53.1.jar -Dwebdriver.chrome.driver=C:\dev\selenium\chromedriver.exe -Dwebdriver.chrome.binary=C:\dev\selenium\chrome-win32\chrome.exe -Dwebdriver.chrome.chrome_binary=C:\dev\selenium\chrome-win32\chrome.exe -Dwebdriver.chrome.capabilities.binary=C:\dev\selenium\chrome-win32\chrome.exe -Dwebdriver.chrome.capabilities.chrome_binary=C:\dev\selenium\chrome-win32\chrome.exe -browser browserName="chrome",version=ANY,platform=WINDOWS,maxInstances=1,binary="C:\dev\selenium\chrome-win32\chrome.exe",chrome_binary="C:\dev\selenium\chrome-win32\chrome.exe" -host 0.0.0.0 -port 4444 binary的变体。但是Selenium Server会忽略这些选项并启动默认的Chrome浏览器。如何让它运行我指定的二进制文件chrome_binary

C:\dev\selenium\chrome-win32\chrome.exe

相关(未答复):

How to specify the Chrome binary location via the selenium server standalone command line?

2 个答案:

答案 0 :(得分:0)

将您的命令更改为以下内容

start java  -Dwebdriver.chrome.driver=C:\dev\selenium\chromedriver.exe
-Dwebdriver.chrome.binary=C:\dev\selenium\chrome-win32\chrome.exe
-Dwebdriver.chrome.chrome_binary=C:\dev\selenium\chrome-win32\chrome.exe
-Dwebdriver.chrome.capabilities.binary=C:\dev\selenium\chrome-win32\chrome.exe
-Dwebdriver.chrome.capabilities.chrome_binary=C:\dev\selenium\chrome-win32\chrome.exe 
-jar selenium-server-standalone-2.53.1.jar -browser browserName="chrome",version=ANY,platform=WINDOWS,maxInstances=1,binary="C:\dev\selenium\chrome-win32\chrome.exe",chrome_binary="C:\dev\selenium\chrome-win32\chrome.exe" -host 0.0.0.0 -port 4444

然后再试一次?您应该将-D JVM参数放在-jar之前。

有关更多信息,请参阅here

答案 1 :(得分:0)

似乎使用Selenium Grid一切正常:

start java -Dwebdriver.server.session.timeout=900 -jar selenium-server-standalone-2.53.1.jar -role hub -host 0.0.0.0 -port 4444
start java -Dwebdriver.chrome.driver=C:\dev\selenium\chromedriver.exe -jar selenium-server-standalone-2.53.1.jar -role node -browser browserName="chrome",version=ANY,platform=WINDOWS,maxInstances=1,chrome_binary="C:\dev\selenium\chrome-win32\chrome.exe" -hub http://127.0.0.1:4444/grid/register -port 5555