1. <tfoot id='Wc1bY'></tfoot>

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

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

      1. <legend id='Wc1bY'><style id='Wc1bY'><dir id='Wc1bY'><q id='Wc1bY'></q></dir></style></legend>

        Node.js 需要而不将其存储到变量中

        时间:2023-09-02
        <legend id='9p4NM'><style id='9p4NM'><dir id='9p4NM'><q id='9p4NM'></q></dir></style></legend>
          • <small id='9p4NM'></small><noframes id='9p4NM'>

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

              <tfoot id='9p4NM'></tfoot>

                <tbody id='9p4NM'></tbody>

                  本文介绍了Node.js 需要而不将其存储到变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有以下代码片段,它在其上下文中工作.

                  I have the following code snippet and it works in its context.

                  "use strict"; 
                  require('chromedriver');
                  var selenium = require('selenium-webdriver');
                  var driver = new selenium.Builder()
                    .forBrowser('chrome')
                    .build();
                  

                  我不明白的是这条线:

                  require('chromedriver');

                  如果我删除它,我会收到错误:

                  If i remove it I get an 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.
                  

                  所以它做了一些事情.

                  我了解 var chromedriver = require('chromedriver'); 的作用,到目前为止我只看到过这样使用 require 函数.

                  I understand what var chromedriver = require('chromedriver'); does and I have only seen the require function being used that way so far.

                  所以我的问题是:require('chromedriver');

                  为什么会起作用?

                  所需的 chromedriver 在哪里结束?

                  Where does the required chromedriver end up?

                  如果 require() 函数没有将返回值保存到变量中,一般会发生什么?

                  What happens in genereal if the require() function does not save its return into a variable?

                  推荐答案

                  在模块上调用 require 实际上会执行模块中的任何代码.在大多数情况下,模块会导出一个或多个函数或对象,您希望将其存储在变量中.但是如果你要写这样的东西:

                  Calling the require on the module actually executes whatever code is in the module. In most cases, the module exports one or more functions or an object, which you want to store in a variable. But if you were to write something like:

                  for (var i = 0;i < 100; i++){
                     console.log("I've been called %d times", i);
                  }
                  

                  在 .js 文件中,然后在节点程序中 require 该文件,您将在控制台中添加 100 行,而没有其他任何事情发生.

                  in a .js file and then require that file in a node program, you'd get 100 lines added to your console and nothing else happening.

                  这篇关于Node.js 需要而不将其存储到变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将 require('chromedriver).path 直接传递给 selenium- 下一篇:Selenium - 元素不可点击

                  相关文章

                  最新文章

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

                1. <legend id='62cMh'><style id='62cMh'><dir id='62cMh'><q id='62cMh'></q></dir></style></legend>
                      <tfoot id='62cMh'></tfoot>

                      <small id='62cMh'></small><noframes id='62cMh'>