Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Jenkins中的Selenium ChromeDriver下载文件_Selenium_Jenkins_Selenium Chromedriver - Fatal编程技术网

使用Jenkins中的Selenium ChromeDriver下载文件

使用Jenkins中的Selenium ChromeDriver下载文件,selenium,jenkins,selenium-chromedriver,Selenium,Jenkins,Selenium Chromedriver,我使用一段Selenium代码(Java)自动下载一个文件(xlxs)并通过电子邮件将其发送给收件人列表 我使用Mavens在Jenkins中集成了这一点,我可以按下按钮下载文件,但是在工作区或服务器上的任何地方都找不到文件 我想让文件附加在电子邮件中,使用詹金斯和发送它 当我在本地执行此操作时,文件将自动下载到默认的“Downloads”文件夹中,但在服务器端它不会执行相同的操作 有关此文件下载位置或如何指定下载文件夹的任何建议 谢谢。注意:我使用Firefox,所以我的代码有点不同 您可以指

我使用一段Selenium代码(Java)自动下载一个文件(xlxs)并通过电子邮件将其发送给收件人列表

我使用Mavens在Jenkins中集成了这一点,我可以按下按钮下载文件,但是在工作区或服务器上的任何地方都找不到文件

我想让文件附加在电子邮件中,使用詹金斯和发送它

当我在本地执行此操作时,文件将自动下载到默认的“Downloads”文件夹中,但在服务器端它不会执行相同的操作

有关此文件下载位置或如何指定下载文件夹的任何建议


谢谢。

注意:我使用Firefox,所以我的代码有点不同

您可以指定下载文件夹或使用现有的自定义浏览器配置文件

使用临时浏览器配置文件:

FirefoxProfile selenium_profile = new FirefoxProfile();
selenium_profile.setPreference("browser.download.folderList",2);    
selenium_profile.setPreference("browser.download.dir", "C:\\Users\\pburgr\\Desktop\\BP_usr_tmp\\");
selenium_profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
options.setProfile(selenium_profile);
使用现有配置文件:

@BeforeClass
public static void setUpClass() {
    FirefoxOptions options = new FirefoxOptions();
    ProfilesIni allProfiles = new ProfilesIni();         
    FirefoxProfile selenium_profile = allProfiles.getProfile("selenium_profile");
    options.setProfile(selenium_profile);
    options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
    System.setProperty("webdriver.gecko.driver", "C:\\Users\\pburgr\\Desktop\\geckodriver-v0.20.0-win64\\geckodriver.exe");
    driver = new FirefoxDriver(options);
    driver.manage().window().maximize();}

我发现文件放在这里:

C:\Program Files (x86)\Google\Chrome\Application\used_version

用你的代码更新问题。代码做了需要做的事情(按下按钮触发文件下载),我不认为在这里添加代码有什么好处。我需要做的是能够将文件发送到某个文件夹,以便使用Jenkins将其附加到电子邮件中。您可能看不到添加代码的优点,但回答问题的人会看到!将代码与问题结合在一起有多种好处,例如:1。它使我们不必提出一些你可能已经尝试过为每个人节省时间的建议,2。它向我们表明,在提出问题之前,你已经做了相当多的研究,最重要的是3。当你给出解决问题的所有信息时,你更有可能得到高质量的答案。我本可以试着回答你的问题,但我不得不写下这篇评论