简体   繁体   English

如何使用Java在Selenium Webdriver中为Firefox配置文件使用相对文件路径?

[英]How to use relative file path for firefox profile in Selenium webdriver using java?

I want to use relative file path in Firefoxprofile function, I have tried all possible ways but its throwing error. 我想在Firefoxprofile函数中使用相对文件路径,我尝试了所有可能的方法,但抛出错误。 Here is my code- profile.setPreference("browser.download.dir", "/downloaded_files/"); 这是我的代码profile.setPreference(“ browser.download.dir”,“ / downloaded_files /”);

folder "downloaded_files" is saved in root directory of my project. 文件夹“ downloaded_files”保存在我项目的根目录中。 I tried all combinations of /,//,\\ still its not downloading filed in desired folder. 我尝试了/,//,\\的所有组合,但仍未将其下载归档到所需的文件夹中。

Try the following 尝试以下

profile.setPreference("browser.download.dir", "./downloaded_files/");

Or 要么

String workingDir = System.getProperty("user.dir");
profile.setPreference("browser.download.dir", workingDir +"/downloaded_files/");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法通过使用Selenium Webdriver设置Firefox配置文件来下载文件 - Unable to download a file by setting Firefox profile using Selenium Webdriver 如何使用Selenium 2 Webdriver打开指定的配置文件Firefox? - How to open specified profile Firefox with Selenium 2 Webdriver? 如何在 Java 中将 Firefox 配置文件和 Firefox 选项与 Selenium 一起使用 - How to use both the Firefox Profile and Firefox options with Selenium in Java 如何使用Selenium WebDriver处理Firefox上载文件窗口-Java - How to handle Firefox Upload File window with Selenium WebDriver - Java 如何使用带有Java的Selenium WebDriver将命令写入Firefox控制台? - How to write commands into the Firefox console using Selenium WebDriver with Java? 如何使用带有Java的Selenium Webdriver在Firefox中禁用不安全密码警告 - How to disable Insecure Password Warning in Firefox using Selenium Webdriver with Java 如何使用 Selenium webdriver 和 Java 为 firefox 设置代理? - How do I set a proxy for firefox using Selenium webdriver with Java? 如何在Java中使用Selenium WebDriver上传文件 - How to upload file using Selenium WebDriver in Java 如何在Selenium Webdriver 3中为Firefox驱动程序设置默认配置文件? - How can I set a default profile for the Firefox driver in Selenium Webdriver 3? Selenium webdriver使用相对路径上传下载文件 - Selenium webdriver upload download files using relative path
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM