Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

269
Views
How can I handle file download pop up for safari using nightwatch

I am trying to use something like this, similar to my firefox options, but my test doesn't seem to handle the download pop-up, any suggestions ? Thank you

"safari": {
      "downloadFolder": "Users/chef/Downloads/",
      "desiredCapabilities": {
        "browserName": "Safari",
        'safari:safariOptions': {
          prefs: {
            'safari.options.dataDir':'Users/chef/Downloads/',
            'safari.helperApps.neverAsk.saveToDisk':'image/jpeg;application/binary;application/pdf;text/plain;application/text;text/xml;application/xml;text/html;text/csv;video/mp4'
          },
        }
      }
    }

I found there were exisitng posts that might provide some context

  • how to handle file downlaod for selenium webdriver for safari
  • How to set Safari download location - Selenium WebDriver
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There are some Selenium methods to switch windows, which you can see in this article: https://saucelabs.com/blog/selenium-tips-working-with-multiple-windows

If you were to store the ID of the original window then use the switchTo() method and go to the original window, hopefully you can handle any issues with interacting with the download pop-up:

//Store the ID of the original window
const originalWindow = await driver.getWindowHandle();

//Check we don't have other windows open already
assert((await driver.getAllWindowHandles()).length === 1);

//Click the link which opens in a new window
await driver.findElement(By.linkText('new window')).click();

//Wait for the new window or tab
await driver.wait(
    async () => (await driver.getAllWindowHandles()).length === 2,
    10000
  );

//Loop through until we find a new window handle
const windows = await driver.getAllWindowHandles();
windows.forEach(async handle => {
  if (handle !== originalWindow) {
    await driver.switchTo().window(handle);
  }
});

//Wait for the new tab to finish loading content
await driver.wait(until.titleIs('Selenium documentation'), 10000);

See the Selenium Docs for additional examples: https://www.selenium.dev/documentation/webdriver/browser_manipulation/#switching-windows-or-tabs.

Not sure if this helps, let me know!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!