簡體   English   中英

如何使用Java在Selenium Webdriver中為Firefox配置文件使用相對文件路徑?

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

我想在Firefoxprofile函數中使用相對文件路徑,我嘗試了所有可能的方法,但拋出錯誤。 這是我的代碼profile.setPreference(“ browser.download.dir”,“ / downloaded_files /”);

文件夾“ downloaded_files”保存在我項目的根目錄中。 我嘗試了/,//,\\的所有組合,但仍未將其下載歸檔到所需的文件夾中。

嘗試以下

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

要么

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM