小编Lou*_*uis的帖子

如何使用Selenium WebDriver手动启动现有的Firefox实例进行测试?

如何使用现有的Firefox实例进行测试?我首先想用手动启动的实例进行一些手动测试然后我想使用现有的浏览器来实现我的自动化脚本.

firefox selenium selenium-webdriver

1
推荐指数
1
解决办法
782
查看次数

NodeJS:TypeError:Buffer不是一个函数(但它是一个函数!)

这个有点困惑.我正在使用一个非常典型的Node + Express设置,我的许多脚本都在操作Buffer对象,它们在任何地方都可以正常工作.除了在一个脚本中,该脚本定义了从ElasticSearch数据存储中检索文档的路径.我正在尝试通过解码base64编码的文件数据字符串来创建一个新的Buffer对象,然后将其发送到浏览器.但即使在调用之前的console.log new Buffer(fildata,'base64')打印出Buffer函数的描述就像你期望的那样,我得到一个异常"TypeError:Buffer不是函数".

相关代码:

var Buffer = require('buffer');
// ... then in the route, inside the callback from the ElasticSearch get() method:
res.setHeader('Content-Type', doc["mimetype"]);
res.setHeader('Content-disposition', 'attachment; filename=' + doc["filename"]);
res.type(doc["mimetype"]);
console.log(Buffer); // Yep, definitely a function here!
res.send(new Buffer(doc["filedata"], 'base64'));
Run Code Online (Sandbox Code Playgroud)

来自节点的输出(注意抛出异常之前的console.log输出):

{ Buffer:
   { [Function: Buffer]
     poolSize: 8192,
     isBuffer: [Function: isBuffer],
     compare: [Function: compare],
     isEncoding: [Function],
     concat: [Function],
     byteLength: [Function: byteLength] },
  SlowBuffer: [Function: SlowBuffer],
  INSPECT_MAX_BYTES: 50,
  kMaxLength: 2147483647 }
/Users/myusername/mynodeproject/routes/retrieve.js:50
                    res.send(new Buffer(doc["filedata"], 'base64'));
                             ^

TypeError: Buffer …
Run Code Online (Sandbox Code Playgroud)

javascript typeerror node.js express

1
推荐指数
1
解决办法
1万
查看次数

RequireJS的代码中“define.amd = {jQuery: true }”的目的是什么?

谁能详细解释一下,为什么在require.js文件中设置了以下代码:

define.amd = {
    jQuery: true
};
Run Code Online (Sandbox Code Playgroud)

参考链接:默认设置为 jquery 为 true

requirejs

1
推荐指数
1
解决办法
1579
查看次数

“找不到模块 fs”

我已经使用过var module = require('/path/to/node_modules/module-name')并且我的所有其他模型都得到了认可,但fs即使我指出了它的位置并确保它已安装,也没有得到认可?我不明白,请帮助

我的控制台给出了这个:http : //prntscr.com/g2akvs

但我所有的其他模块都很好

正如您可以通过我的参考看到的:http : //prntscr.com/g2akzm

javascript node.js node-modules

1
推荐指数
1
解决办法
2072
查看次数

使用Python脚本运行WebDriver时出错

我在使用库selenium在python中使用脚本运行执行Webdriver时遇到了问题.我发布了示例代码方案以及执行时抛出的相应错误.

代码场景:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://www.python.org")
Run Code Online (Sandbox Code Playgroud)

错误场景:

Traceback (most recent call last):

  File "C:/Users/Kaushik/Desktop/IMC DEVELOPER TEST/Sample.py", line 4, in <module>
    driver = webdriver.Firefox()

  File "C:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\firefox\webdriver.py", line 59, in __init__
    self.binary, timeout),

  File "C:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\firefox\extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)

  File "C:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\firefox\firefox_binary.py", line 60, in launch_browser
    self._start_from_profile_path(self.profile.path)

  File "C:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\firefox\firefox_binary.py", line 83, in _start_from_profile_path
    env=self._firefox_env).communicate()

  File "C:\Python27\lib\subprocess.py", line 709, in __init__
    errread, errwrite)

  File "C:\Python27\lib\subprocess.py", line 957, in _execute_child
    startupinfo)
WindowsError: [Error 87] The parameter …
Run Code Online (Sandbox Code Playgroud)

python selenium web-scraping

0
推荐指数
1
解决办法
402
查看次数

如何在全局和本地函数中使用require

我使用节点JS aplication并且我用模块创建了新的js文件.在这个模块中我只导出一个函数,在这个模块中我可以说我还有两个函数仅供内部使用,不应该暴露在外面,每个函数都使用不同的需要模块如下:

module.exports = function (app, express) {

    var bodyParser = require('body-parser'),
        url = require('url'),
        http = require('http');

.....
};


function prRequest(req, res) {

    httpProxy = require('http-proxy');
....

}

function postRequest(req, res) {

 url = require('url');
....

}
Run Code Online (Sandbox Code Playgroud)

我的问题来自最佳实践,我应该在哪里提出要求(对于网址http等)

1.在所有需要它的功能中?在我的情况下内部和外部

2.globally在每个函数可以使用的文件中?

3.如果两个不行,我应该在哪里放置我应该在两个函数中使用的require URL?更好地放入函数或全局或者无关紧要

javascript require node.js

0
推荐指数
1
解决办法
1996
查看次数

获取错误:找到参数'--webdriver-port',这是不期望的,或者在此上下文中无效

当我运行我的selenium代码时,我收到错误"错误:找到参数'--webdriver-port'这是不期望的,或者在此上下文中无效"

我正在使用Firefox 48.0使用gecko驱动程序我已经初始化了浏览器.并得到上述错误.

java testing selenium firefox-marionette geckodriver

-1
推荐指数
1
解决办法
1020
查看次数

为什么之后不能设置const指针?

我知道这可能是一个微不足道的问题.在声明之后无法设置const指针的逻辑是什么?这并不是说分配内存会改变const引用的起始地址.那么为什么不能......

int* const p;
p = new int [10];
Run Code Online (Sandbox Code Playgroud)

...完成...这也禁止将const指针传递给函数?

c++ pointers const function

-8
推荐指数
1
解决办法
623
查看次数