3

I am running chimp to automate some of my test cases. In one of them, I have to download a file and check if the file size matches. I was able to download the file automatically when clicking on its link in chrome by defining the following prefs in Webdriver.io section of chimp config file:

prefs: {"profile.default_content_settings.popups": false, "download.default_directory": "./downloads"}

Now, I'm trying to do the same with Firefox. However, I am still not able to do it. I read that I would need to create a firefox profile and pass the following Firefox preferences:

"browser.download.folderList",2
"browser.download.manager.showWhenStarting",false
"browser.download.dir", "/save/file/to/this/directory"
"browser.helperApps.neverAsk.saveToDisk","text/html, application/xhtml+xml, application/xml, application/csv, text/plain, application/vnd.ms-excel, text/csv, text/comma-separated-values, application/octet-stream"

Is there a way to do that in the Webdriver.io section of chimp config file, just like I did for Chrome?

By the way, I did install npm package firefox profile. Tried to use the code below to start the browser directly in my step defs, but I get the following error:

[chimp] Detected an unhandledRejection: [chimp][hooks] Error: Couldn't connect to selenium server at end() - ula_software_step_defs.js:42:1

this.Given(/^The Home page with FF profile$/, function () {
    let fp = new FirefoxProfile();
    fp.setPreference("browser.download.folderList",2);
    fp.setPreference("browser.download.manager.showWhenStarting",false);
    fp.setPreference("browser.download.dir", "./downloads");
    fp.setPreference("browser.helperApps.neverAsk.saveToDisk","text/html, application/xhtml+xml, application/xml, application/csv, text/plain, application/vnd.ms-excel, text/csv, text/comma-separated-values, application/octet-stream");

     fp.encoded(function(prof) {

      let client = webdriverio.remote({
        desiredCapabilities: {
          browserName: 'firefox',
          firefox_profile: prof
        }
      });

      client
        .init()
        .url("www.google.com.br", shared.defaultTimeout)
        .pause(10000)
        .end();

    });

Could someone, please, help out?

0 Answers0