• <bdo id='wRD3Z'></bdo><ul id='wRD3Z'></ul>
    <legend id='wRD3Z'><style id='wRD3Z'><dir id='wRD3Z'><q id='wRD3Z'></q></dir></style></legend>
    <i id='wRD3Z'><tr id='wRD3Z'><dt id='wRD3Z'><q id='wRD3Z'><span id='wRD3Z'><b id='wRD3Z'><form id='wRD3Z'><ins id='wRD3Z'></ins><ul id='wRD3Z'></ul><sub id='wRD3Z'></sub></form><legend id='wRD3Z'></legend><bdo id='wRD3Z'><pre id='wRD3Z'><center id='wRD3Z'></center></pre></bdo></b><th id='wRD3Z'></th></span></q></dt></tr></i><div id='wRD3Z'><tfoot id='wRD3Z'></tfoot><dl id='wRD3Z'><fieldset id='wRD3Z'></fieldset></dl></div>

      <tfoot id='wRD3Z'></tfoot>

      1. <small id='wRD3Z'></small><noframes id='wRD3Z'>

      2. 将 require('chromedriver).path 直接传递给 selenium-

        时间:2023-09-02
        <i id='m2Dth'><tr id='m2Dth'><dt id='m2Dth'><q id='m2Dth'><span id='m2Dth'><b id='m2Dth'><form id='m2Dth'><ins id='m2Dth'></ins><ul id='m2Dth'></ul><sub id='m2Dth'></sub></form><legend id='m2Dth'></legend><bdo id='m2Dth'><pre id='m2Dth'><center id='m2Dth'></center></pre></bdo></b><th id='m2Dth'></th></span></q></dt></tr></i><div id='m2Dth'><tfoot id='m2Dth'></tfoot><dl id='m2Dth'><fieldset id='m2Dth'></fieldset></dl></div>
          • <bdo id='m2Dth'></bdo><ul id='m2Dth'></ul>
              <tbody id='m2Dth'></tbody>

              1. <small id='m2Dth'></small><noframes id='m2Dth'>

                <tfoot id='m2Dth'></tfoot>

                  <legend id='m2Dth'><style id='m2Dth'><dir id='m2Dth'><q id='m2Dth'></q></dir></style></legend>
                  本文介绍了将 require('chromedriver).path 直接传递给 selenium-webdriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  tl;dr: 有谁知道如何在不设置 PATH 环境变量的情况下在代码中将 chromedriver 的路径传递给 selenium-webdriver?

                  我正在尝试将 selenium-webdriver 与 chrome 一起使用,但不希望物理安装 chromedriver 并操纵路径.我有以下代码:

                  I'm attempting to use selenium-webdriver with chrome, but would prefer to not physically install chromedriver and manipulate the path. I have the following code:

                  var webdriver = require('selenium-webdriver');
                  var driver = new webdriver.Builder().
                      withCapabilities(webdriver.Capabilities.chrome()).
                      build();
                  

                  没有在路径中设置 chromedriver,这会引发错误:

                  Without chromedriver set in the path, this throws the error:

                  Error: The ChromeDriver could not be found on the current PATH. Please download the latest 
                  version of the ChromeDriver from http://chromedriver.storage.googleapis.com/index.html and 
                  ensure it can be found on your PATH.
                  

                  我不想设置我的路径,所以我从 npm 安装了 chromedriver 并添加到我的 package.json:

                  I'd prefer not have to setup my path, so I've installed chromedriver from npm and added to my package.json:

                  "scripts": {
                      "preinstall-chromedriver": "npm install",
                      "install-chromedriver": "node node_modules/chromedriver/install.js",
                      "pretest_e2e": "npm run install-chromedriver",
                      "test_e2e": "node release/test/rune2e.js"
                  },
                  

                  现在我已经安装了 chromedriver,并且可以使用 require('chromedriver').path 获取路径,但是我无法将它传递给 selenium-webdriver.有人知道吗?

                  Now I have chromedriver installed and can get the path with require('chromedriver').path, but I have no way of passing this to the selenium-webdriver. Anyone know?

                  推荐答案

                  你需要创建 &设置您自己的默认 chrome 服务.

                  You need to create & set your own default chrome service.

                  var webdriver = require('selenium-webdriver');
                  var chrome = require('selenium-webdriver/chrome');
                  var path = require('chromedriver').path;
                  
                  var service = new chrome.ServiceBuilder(path).build();
                  chrome.setDefaultService(service);
                  
                  var driver = new webdriver.Builder()
                      .withCapabilities(webdriver.Capabilities.chrome())
                      .build();
                  

                  这篇关于将 require('chromedriver).path 直接传递给 selenium-webdriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用 selenium 将网页滚动到目标元素 下一篇:Node.js 需要而不将其存储到变量中

                  相关文章

                  最新文章

                  • <bdo id='FtCzi'></bdo><ul id='FtCzi'></ul>
                  <tfoot id='FtCzi'></tfoot>
                  1. <i id='FtCzi'><tr id='FtCzi'><dt id='FtCzi'><q id='FtCzi'><span id='FtCzi'><b id='FtCzi'><form id='FtCzi'><ins id='FtCzi'></ins><ul id='FtCzi'></ul><sub id='FtCzi'></sub></form><legend id='FtCzi'></legend><bdo id='FtCzi'><pre id='FtCzi'><center id='FtCzi'></center></pre></bdo></b><th id='FtCzi'></th></span></q></dt></tr></i><div id='FtCzi'><tfoot id='FtCzi'></tfoot><dl id='FtCzi'><fieldset id='FtCzi'></fieldset></dl></div>
                    <legend id='FtCzi'><style id='FtCzi'><dir id='FtCzi'><q id='FtCzi'></q></dir></style></legend>

                    <small id='FtCzi'></small><noframes id='FtCzi'>