Reputation: 77
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
Upvotes: 2
Views: 757
Reputation: 101
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!
Upvotes: 2