量角器 - Jasmine - 将文件下载到相对路径 [英] Protractor - Jasmine - Download file to a relative path
问题描述
我已阅读并按照以下问题及其评论/答案:
I've read and follow the below questions here and its comments/answers:
问题1
问题2
问题3
Question 1
Question 2
Question 3
但是找不到使用 absolutePath
的方法,因为我需要让这个测试在另一个上运行机器,所以,我需要相对于项目没有其他文件夹在它之外。我怎么能做到这一点?
But could not find a way not to use absolutePath
, since I need to have this tests run on another machine, so, I need to be relative to the project no the other folder outside of it. how can I accomplish that?
推荐答案
如您所引用的问题所述,您可以使用以下选项控制文件的下载位置
As explained in the questions you have quoted, You can control where the file downloads using the below option
'chromeOptions': {
prefs: {
download: {
'prompt_for_download': false,
'default_directory': <<absolutePath>>
}
}
}
关于如何提出你的问题要在不同的机器上运行时完成此操作,答案是 - 从相对路径生成绝对路径并将其传递到Chrome选项。
Coming to your question on how to accomplish this when running on different machines, the answer is - Generate absolute Path from relative path and pass it onto Chrome Options.
var path = require('path');
var downloadsPath = path.resolve(__dirname, './downloads');
................
'chromeOptions': {
prefs: {
download: {
'prompt_for_download': false,
'default_directory': downloadsPath
}
}
}
这篇关于量角器 - Jasmine - 将文件下载到相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!