Set a custom Firefox profile or use an existing profile for your tests that run on Firefox browsers in BrowserStack Automate.
Firefox profiles include custom preferences that you would like to simulate an environment for your test script. For example, you might want to create a profile that sets preferences to handle the download popup programmatically during your test run.
The following sections include sample code snippets to create a profile or use an existing profile with preferences that handle the download popup and succesfully downloads the file.
usingSystem.Collections.Generic;usingSystem.Threading;usingOpenQA.Selenium.Firefox;usingOpenQA.Selenium.Remote;usingOpenQA.Selenium;usingSystem.IO;usingSystem;usingSystem.Text;namespaceSeleniumTest{classProgram{publicstaticvoidMain(string[] args){FirefoxProfile firefoxProfile =newFirefoxProfile();
firefoxProfile.SetPreference("browser.download.showWhenStarting",false);
firefoxProfile.SetPreference("browser.download.folderList",1);
firefoxProfile.SetPreference("browser.download.manager.focusWhenStarting",false);
firefoxProfile.SetPreference("browser.download.useDownloadDir",true);
firefoxProfile.SetPreference("browser.helperApps.alwaysAsk.force",false);
firefoxProfile.SetPreference("browser.download.manager.alertOnEXEOpen",false);
firefoxProfile.SetPreference("browser.download.manager.closeWhenDone",true);
firefoxProfile.SetPreference("browser.download.manager.showAlertOnComplete",false);
firefoxProfile.SetPreference("browser.download.manager.useWindow",false);
firefoxProfile.SetPreference("browser.helperApps.neverAsk.saveToDisk","application/octet-stream");FirefoxOptions capabilities =newFirefoxOptions();Dictionary<string,object> browserstackOptions =newDictionary<string,object>();
browserstackOptions.Add("os","OS X");
browserstackOptions.Add("osVersion","catalina");
browserstackOptions.Add("useW3C","true");
browserstackOptions.Add("buildName","Selenium C# Firefox Profile");
browserstackOptions.Add("userName","YOUR_USERNAME");
browserstackOptions.Add("accessKey","YOUR_ACCESS_KEY");
capabilities.AddAdditionalOption("bstack:options", browserstackOptions);
capabilities.Profile = firefoxProfile;RemoteWebDriver driver =newRemoteWebDriver(newUri("https://hub-cloud.browserstack.com/wd/hub"), capabilities
);// Navigate to the link
driver.Navigate().GoToUrl("https://www.browserstack.com/test-on-the-right-mobile-devices");IJavaScriptExecutor jse =(IJavaScriptExecutor)driver;
Thread.Sleep(2000);// This will scroll the page till the element is found
driver.ExecuteScript("arguments[0].scrollIntoView();", driver.FindElementByClassName("icon-csv"));
driver.ExecuteScript("window.scrollBy(0,-100)");
Thread.Sleep(2000);// Find element by class name and then click"
driver.FindElementByClassName("icon-csv").Click();
Thread.Sleep(1000);
driver.ExecuteScript("browserstack_executor: {\"action\": \"fileExists\"}");
driver.ExecuteScript("browserstack_executor: {\"action\": \"getFileProperties\"}");
driver.Quit();}}}
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import time
from selenium.webdriver.firefox.options import Options as FirefoxOptions
options = FirefoxOptions()
options.set_preference('browser.download.folderList',1)
options.set_preference('browser.download.manager.showWhenStarting',False)
options.set_preference('browser.download.manager.focusWhenStarting',False)
options.set_preference('browser.download.useDownloadDir',True)
options.set_preference('browser.helperApps.alwaysAsk.force',False)
options.set_preference('browser.download.manager.alertOnEXEOpen',False)
options.set_preference('browser.download.manager.closeWhenDone',True)
options.set_preference('browser.download.manager.showAlertOnComplete',False)
options.set_preference('browser.download.manager.useWindow',False)# You will need to find the content-type of your app and set it here. We are downloading a gzip file.
options.set_preference('browser.helperApps.neverAsk.saveToDisk','application/octet-stream')# options.update_preferences()
caps ={"os":"OS X","osVersion":"Catalina","buildName":"firefoxprofile- node","sessionName":"firefoxprofile- node","local":"false","userName":"YOUR_USERNAME","accessKey":"YOUR_ACCESS_KEY",}
options.set_capability('bstack:options', caps)
options.set_capability('browserVersion','95')
options.set_capability('browserName','Firefox')
driver = webdriver.Remote(
command_executor='https://hub.browserstack.com/wd/hub',
options=options)# Navigate to the link
driver.get("https://www.browserstack.com/test-on-the-right-mobile-devices")# Accept the cookie popup
test=driver.find_element_by_id("accept-cookie-notification").click()
time.sleep(2)# Find element by class name and store in variable "element"
element = driver.find_element_by_class_name("icon-csv")
driver.execute_script("arguments[0].scrollIntoView();", element)
driver.execute_script("window.scrollBy(0,-100)")
time.sleep(2)# Click on the element to download the file
clicked = element.click()
time.sleep(2)
driver.quit()
require'rubygems'require'selenium-webdriver'# Input capabilities
options =Selenium::WebDriver::Firefox::Options.new
options.add_preference('browser.download.folderList',1)
options.add_preference('browser.download.manager.showWhenStarting',false)
options.add_preference('browser.download.manager.showWhenStarting',false)
options.add_preference('browser.download.useDownloadDir',true)
options.add_preference('browser.helperApps.alwaysAsk.force',false)
options.add_preference('browser.download.manager.alertOnEXEOpen',false)
options.add_preference('browser.download.manager.closeWhenDone',true)
options.add_preference('browser.download.manager.showAlertOnComplete',true)
options.add_preference('browser.download.manager.useWindow',false)# You will need to find the content-type of your app and set it here.
options.add_preference('browser.helperApps.neverAsk.saveToDisk','application/octet-stream')
options.browser_version ='95'
bstack_options ={"os"=>"OS X","osVersion"=>"Sierra","buildName"=>"Final-Snippet-Test","sessionName"=>"Selenium-4 Ruby snippet test","userName"=>"YOUR_USERNAME","accessKey"=>"YOUR_ACCESS_KEY",}
options.add_option('bstack:options', bstack_options)
driver =Selenium::WebDriver.for(:remote,:url=>"https://hub-cloud.browserstack.com/wd/hub",:capabilities=> options)
driver.navigate.to "https://www.browserstack.com/test-on-the-right-mobile-devices"
test = driver.find_element(id:"accept-cookie-notification").click
sleep(4)
element = driver.find_element(class:"icon-csv")
driver.execute_script("arguments[0].scrollIntoView();", element)
driver.execute_script("window.scrollBy(0,-100)")
sleep(2)
clicked = element.click()
sleep(2)
driver.quit
importorg.openqa.selenium.By;importorg.openqa.selenium.JavascriptExecutor;importorg.openqa.selenium.Platform;importorg.openqa.selenium.WebDriver;importorg.openqa.selenium.WebElement;importorg.openqa.selenium.firefox.FirefoxProfile;importorg.openqa.selenium.interactions.ClickAction;importorg.openqa.selenium.firefox.FirefoxDriver;importorg.openqa.selenium.remote.DesiredCapabilities;importorg.openqa.selenium.remote.RemoteWebDriver;importorg.openqa.selenium.firefox.*;importjava.net.URL;publicclassJavaSample{publicstaticfinalString AUTOMATE_USERNAME ="YOUR_USERNAME";publicstaticfinalString AUTOMATE_KEY ="YOUR_ACCESS_KEY";publicstaticfinalString URL ="https://"+ AUTOMATE_USERNAME +":"+ AUTOMATE_KEY +"@hub-cloud.browserstack.com/wd/hub";publicstaticvoidmain(String[] args)throwsException{FirefoxProfile profile =newFirefoxProfile();
profile.setPreference("browser.download.folderList",1);
profile.setPreference("browser.download.manager.showWhenStarting",false);
profile.setPreference("browser.download.manager.focusWhenStarting",false);
profile.setPreference("browser.download.useDownloadDir",true);
profile.setPreference("browser.helperApps.alwaysAsk.force",false);
profile.setPreference("browser.download.manager.alertOnEXEOpen",false);
profile.setPreference("browser.download.manager.closeWhenDone",true);
profile.setPreference("browser.download.manager.showAlertOnComplete",false);
profile.setPreference("browser.download.manager.useWindow",false);
profile.setPreference("browser.helperApps.alwaysAsk.force",false);// You will need to find the content-type of your app and set it here.
profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/octet-stream");FirefoxOptions capabilities =newFirefoxOptions();
capabilities.setCapability("browser","Firefox");
capabilities.setCapability("browser_version","latest");
capabilities.setCapability("os","Windows");
capabilities.setCapability("os_version","10");
capabilities.setCapability("build","Selenium Java Firefox Profile");
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
capabilities.setProfile(profile);WebDriver driver =newRemoteWebDriver(newURL(URL), capabilities);
driver.get("https://www.browserstack.com/test-on-the-right-mobile-devices");JavascriptExecutor jse =(JavascriptExecutor)driver;
jse.executeScript("arguments[0].scrollIntoView();", driver.findElement(By.className("icon-csv")));
jse.executeScript("window.scrollBy(0,-100)");Thread.sleep(2000);WebElement element = driver.findElement(By.className("icon-csv"));
element.click();Thread.sleep(2000);
jse.executeScript("browserstack_executor: {\"action\": \"fileExists\"}");
jse.executeScript("browserstack_executor: {\"action\": \"getFileProperties\"}");
driver.quit();}}
const{
Builder,
By,
Key,
until
}=require('selenium-webdriver');const fs =require("fs");const webdriver =require('selenium-webdriver');const bb =require('bluebird');var sleep =require('sleep');var FirefoxProfile =require('firefox-profile');var profile =newFirefoxProfile();
profile.setPreference('browser.download.folderList',1);
profile.setPreference('browser.download.manager.showWhenStarting',false);
profile.setPreference('browser.download.manager.focusWhenStarting',false);
profile.setPreference('browser.download.useDownloadDir',true);
profile.setPreference('browser.helperApps.alwaysAsk.force',false);
profile.setPreference('browser.download.manager.alertOnEXEOpen',false);
profile.setPreference('browser.download.manager.closeWhenDone',true);
profile.setPreference('browser.download.manager.showAlertOnComplete',false);
profile.setPreference('browser.download.manager.useWindow',false);// You will need the content-type of your app from developer tools on your browser and set it here. We are downloading a csv file.
profile.setPreference('browser.helperApps.neverAsk.saveToDisk','application/octet-stream');
profile.updatePreferences();
profile.encode((err, encoded)=>{let capabilities ={'browserName':'firefox','browser_version':'latest','os':'Windows','os_version':'10','browserstack.user':'YOUR_USERNAME','browserstack.key':'YOUR_ACCESS_KEY','build':'Selenium NodeJS Firefox Profile','firefox_profile': encoded
}var driver =newwebdriver.Builder().usingServer('https://hub-cloud.browserstack.com/wd/hub').withCapabilities(capabilities).build();// Navigate to the link
driver.get('https://www.browserstack.com/test-on-the-right-mobile-devices').then(function(){// Find element by class name and store in variable "element"
driver.findElement(By.className('icon-csv')).then(function(element){// This will scroll the page till the element is found
driver.executeScript('arguments[0].scrollIntoView();', element).then(function(){
driver.executeScript('window.scrollBy(0,-200)').then(function(){// Accept the cookie popup
driver.findElement(By.id("accept-cookie-notification")).click().then(function(){// Click on the element to download the file
element.click().then(function(){
bb.delay(5000).then(function(){
driver.quit();});});});});});});});});
usingSystem.Collections.Generic;usingSystem.Threading;usingOpenQA.Selenium.Firefox;usingOpenQA.Selenium.Remote;usingOpenQA.Selenium;usingSystem.IO;usingSystem;usingSystem.Text;namespaceSeleniumTest{classProgram{publicstaticvoidMain(string[] args){FirefoxProfile firefoxProfile =newFirefoxProfile();
firefoxProfile.SetPreference("browser.download.showWhenStarting",false);
firefoxProfile.SetPreference("browser.download.folderList",1);
firefoxProfile.SetPreference("browser.download.manager.focusWhenStarting",false);
firefoxProfile.SetPreference("browser.download.useDownloadDir",true);
firefoxProfile.SetPreference("browser.helperApps.alwaysAsk.force",false);
firefoxProfile.SetPreference("browser.download.manager.alertOnEXEOpen",false);
firefoxProfile.SetPreference("browser.download.manager.closeWhenDone",true);
firefoxProfile.SetPreference("browser.download.manager.showAlertOnComplete",false);
firefoxProfile.SetPreference("browser.download.manager.useWindow",false);
firefoxProfile.SetPreference("browser.helperApps.neverAsk.saveToDisk","application/octet-stream");FirefoxOptions capabilities =newFirefoxOptions();
capabilities.AddAdditionalCapability("os","os x",true);
capabilities.AddAdditionalCapability("os_version","monterey",true);
capabilities.AddAdditionalCapability("build","Firefox Profile C# Selenium3",true);
capabilities.AddAdditionalCapability("browser","firefox",true);
capabilities.AddAdditionalCapability("browser_version","latest",true);
capabilities.AddAdditionalCapability("browserstack.user","YOUR_USERNAME",true);
capabilities.AddAdditionalCapability("browserstack.key","YOUR_ACCESS_KEY",true);
capabilities.Profile = firefoxProfile;RemoteWebDriver driver =newRemoteWebDriver(newUri("https://hub-cloud.browserstack.com/wd/hub"), capabilities
);// Navigate to the link
driver.Navigate().GoToUrl("https://www.browserstack.com/test-on-the-right-mobile-devices");IJavaScriptExecutor jse =(IJavaScriptExecutor)driver;
Thread.Sleep(2000);// This will scroll the page till the element is found
driver.ExecuteScript("arguments[0].scrollIntoView();", driver.FindElementByClassName("icon-csv"));
driver.ExecuteScript("window.scrollBy(0,-100)");
Thread.Sleep(2000);// Find element by class name and then click"
driver.FindElementByClassName("icon-csv").Click();
Thread.Sleep(1000);
driver.ExecuteScript("browserstack_executor: {\"action\": \"fileExists\"}");
driver.ExecuteScript("browserstack_executor: {\"action\": \"getFileProperties\"}");
driver.Quit();}}}
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import time
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList',1)
profile.set_preference('browser.download.manager.showWhenStarting',False)
profile.set_preference('browser.download.manager.focusWhenStarting',False)
profile.set_preference('browser.download.useDownloadDir',True)
profile.set_preference('browser.helperApps.alwaysAsk.force',False)
profile.set_preference('browser.download.manager.alertOnEXEOpen',False)
profile.set_preference('browser.download.manager.closeWhenDone',True)
profile.set_preference('browser.download.manager.showAlertOnComplete',False)
profile.set_preference('browser.download.manager.useWindow',False)# You will need to find the content-type of your app and set it here. We are downloading a gzip file.
profile.set_preference('browser.helperApps.neverAsk.saveToDisk','application/octet-stream')
profile.update_preferences()
desired_cap ={'browser':'Firefox','browser_version':'latest','os':'OS X','os_version':'Monetery','build':'Selenium Python Firefox Profile'}
driver = webdriver.Remote(
command_executor='https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub.browserstack.com/wd/hub',
desired_capabilities=desired_cap, browser_profile=profile)# Navigate to the link
driver.get("https://www.browserstack.com/test-on-the-right-mobile-devices")# Accept the cookie popup
test=driver.find_element_by_id("accept-cookie-notification").click()
time.sleep(2)# Find element by class name and store in variable "element"
element = driver.find_element_by_class_name("icon-csv")
driver.execute_script("arguments[0].scrollIntoView();", element)
driver.execute_script("window.scrollBy(0,-100)")
time.sleep(2)# Click on the element to download the file
clicked = element.click()
time.sleep(2)
driver.execute_script("browserstack_executor: {\"action\": \"fileExists\"}")
driver.execute_script("browserstack_executor: {\"action\": \"getFileProperties\"}")
driver.quit()
require'rubygems'require'selenium-webdriver'# Input capabilities
profile =Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.folderList']=1
profile['browser.download.manager.showWhenStarting']=false
profile['browser.download.manager.focusWhenStarting']=false
profile['browser.download.useDownloadDir']=true
profile['browser.helperApps.alwaysAsk.force']=false
profile['browser.download.manager.alertOnEXEOpen']=false
profile['browser.download.manager.closeWhenDone']=true
profile['browser.download.manager.showAlertOnComplete']=false
profile['browser.download.manager.useWindow']=false# You will need to find the content-type of your app and set it here.
profile['browser.helperApps.neverAsk.saveToDisk']="application/octet-stream"
options =Selenium::WebDriver::Firefox::Options.new(profile: profile)
caps =Selenium::WebDriver::Remote::Capabilities.firefox(:options=> profile)
caps['browser']='Firefox'
caps['browser_version']='latest'
caps['os']='OS X'
caps['os_version']='Monterey'
caps['name']='Bstack-[Ruby] Sample file download'
caps["javascriptEnabled"]="true"
driver =Selenium::WebDriver.for(:remote,:url=>"https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub",:desired_capabilities=> caps)
driver.navigate.to "https://www.browserstack.com/test-on-the-right-mobile-devices"
test = driver.find_element(id:"accept-cookie-notification").click
sleep(4)
element = driver.find_element(class:"icon-csv")
driver.execute_script("arguments[0].scrollIntoView();", element)
driver.execute_script("window.scrollBy(0,-100)")
sleep(2)
clicked = element.click()
sleep(2)# driver.find_element(:id => 'download').click
driver.quit
Use an existing Firefox profile
Using an existing profile from your local machine involves the following steps:
usingSystem.Collections.Generic;usingSystem.Threading;usingOpenQA.Selenium.Firefox;usingOpenQA.Selenium.Remote;usingOpenQA.Selenium;usingSystem.IO;usingSystem;usingSystem.Text;namespaceSeleniumTest{classProgram{publicstaticvoidMain(string[] args){FirefoxProfile firefoxProfile =newFirefoxProfile("/Users/test/Library/Application Support/Firefox/Profiles/<name_of_your_profile>");FirefoxOptions capabilities =newFirefoxOptions();Dictionary<string,object> browserstackOptions =newDictionary<string,object>();
browserstackOptions.Add("os","OS X");
browserstackOptions.Add("osVersion","catalina");
browserstackOptions.Add("useW3C","true");
browserstackOptions.Add("buildName","Selenium C# Firefox Profile");
browserstackOptions.Add("userName","YOUR_USERNAME");
browserstackOptions.Add("accessKey","YOUR_ACCESS_KEY");
capabilities.AddAdditionalOption("bstack:options", browserstackOptions);
capabilities.Profile = firefoxProfile;RemoteWebDriver driver =newRemoteWebDriver(newUri("https://hub-cloud.browserstack.com/wd/hub"), capabilities
);// Navigate to the link
driver.Navigate().GoToUrl("https://www.browserstack.com/test-on-the-right-mobile-devices");IJavaScriptExecutor jse =(IJavaScriptExecutor)driver;
Thread.Sleep(2000);// This will scroll the page till the element is found
driver.ExecuteScript("arguments[0].scrollIntoView();", driver.FindElementByClassName("icon-csv"));
driver.ExecuteScript("window.scrollBy(0,-100)");
Thread.Sleep(2000);// Find element by class name and then click"
driver.FindElementByClassName("icon-csv").Click();
Thread.Sleep(1000);
driver.ExecuteScript("browserstack_executor: {\"action\": \"fileExists\"}");
driver.ExecuteScript("browserstack_executor: {\"action\": \"getFileProperties\"}");
driver.Quit();}}}
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import time
options = webdriver.FirefoxOptions()
options.set_preference('profile',"/Users/test/Library/Application Support/Firefox/Profiles/<name_of_your_profile>")
caps ={"os":"OS X","osVersion":"Monterey","buildName":"firefoxprofile- python","sessionName":"firefoxprofile- python","browserName":"Firefox",}
options.set_capability('bstack:options', caps)
driver = webdriver.Remote(
command_executor='https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub.browserstack.com/wd/hub',
options=options)# Navigate to the link
driver.get("https://www.browserstack.com/test-on-the-right-mobile-devices")# Accept the cookie popup
test=driver.find_element_by_id("accept-cookie-notification").click()
time.sleep(2)# Find element by class name and store in variable "element"
element = driver.find_element_by_class_name("icon-csv")
driver.execute_script("arguments[0].scrollIntoView();", element)
driver.execute_script("window.scrollBy(0,-100)")
time.sleep(2)# Click on the element to download the file
clicked = element.click()
time.sleep(2)
driver.quit()
const{
Builder,
By,
Key,
until
}=require('selenium-webdriver');const fs =require("fs");const webdriver =require('selenium-webdriver');const bb =require('bluebird');var sleep =require('sleep');var FirefoxProfile =require('firefox-profile');var profile =newFirefoxProfile("/Users/test/Library/Application Support/Firefox/Profiles/<name_of_your_profile>");
profile.updatePreferences();
profile.encode((err, encoded)=>{let capabilities ={'browserName':'firefox','browser_version':'latest','os':'OS X','os_version':'Monterey','browserstack.user':'YOUR_USERNAME','browserstack.key':'YOUR_ACCESS_KEY','build':'Selenium NodeJS Firefox Profile','firefox_profile': encoded
}var driver =newwebdriver.Builder().usingServer('https://hub-cloud.browserstack.com/wd/hub').withCapabilities(capabilities).build();// Navigate to the link
driver.get('https://www.browserstack.com/test-on-the-right-mobile-devices').then(function(){// Find element by class name and store in variable "element"
driver.findElement(By.className('icon-csv')).then(function(element){// This will scroll the page till the element is found
driver.executeScript('arguments[0].scrollIntoView();', element).then(function(){
driver.executeScript('window.scrollBy(0,-200)').then(function(){// Accept the cookie popup
driver.findElement(By.id("accept-cookie-notification")).click().then(function(){// Click on the element to download the file
element.click().then(function(){
bb.delay(5000).then(function(){
driver.quit();});});});});});});});});
usingSystem.Collections.Generic;usingSystem.Threading;usingOpenQA.Selenium.Firefox;usingOpenQA.Selenium.Remote;usingOpenQA.Selenium;usingSystem.IO;usingSystem;usingSystem.Text;namespaceSeleniumTest{classProgram{publicstaticvoidMain(string[] args){FirefoxProfile firefoxProfile =newFirefoxProfile("/Users/test/Library/Application Support/Firefox/Profiles/<name_of_your_profile>");FirefoxOptions capabilities =newFirefoxOptions();
capabilities.AddAdditionalCapability("os","os x",true);
capabilities.AddAdditionalCapability("os_version","monterey",true);
capabilities.AddAdditionalCapability("build","Firefox Profile C# Selenium3",true);
capabilities.AddAdditionalCapability("browser","firefox",true);
capabilities.AddAdditionalCapability("browser_version","latest",true);
capabilities.AddAdditionalCapability("browserstack.user","YOUR_USERNAME",true);
capabilities.AddAdditionalCapability("browserstack.key","YOUR_ACCESS_KEY",true);
capabilities.Profile = firefoxProfile;RemoteWebDriver driver =newRemoteWebDriver(newUri("https://hub-cloud.browserstack.com/wd/hub"), capabilities
);// Navigate to the link
driver.Navigate().GoToUrl("https://www.browserstack.com/test-on-the-right-mobile-devices");IJavaScriptExecutor jse =(IJavaScriptExecutor)driver;
Thread.Sleep(2000);// This will scroll the page till the element is found
driver.ExecuteScript("arguments[0].scrollIntoView();", driver.FindElementByClassName("icon-csv"));
driver.ExecuteScript("window.scrollBy(0,-100)");
Thread.Sleep(2000);// Find element by class name and then click"
driver.FindElementByClassName("icon-csv").Click();
Thread.Sleep(1000);
driver.ExecuteScript("browserstack_executor: {\"action\": \"fileExists\"}");
driver.ExecuteScript("browserstack_executor: {\"action\": \"getFileProperties\"}");
driver.Quit();}}}
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import time
profile = webdriver.FirefoxProfile("/Users/test/Library/Application Support/Firefox/Profiles/<name_of_your_profile>")
profile.update_preferences()
desired_cap ={'browser':'Firefox','browser_version':'latest','os':'OS X','os_version':'Monetery','build':'Selenium Python Firefox Profile'}
driver = webdriver.Remote(
command_executor='https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub.browserstack.com/wd/hub',
desired_capabilities=desired_cap, browser_profile=profile)# Navigate to the link
driver.get("https://www.browserstack.com/test-on-the-right-mobile-devices")# Accept the cookie popup
test=driver.find_element_by_id("accept-cookie-notification").click()
time.sleep(2)# Find element by class name and store in variable "element"
element = driver.find_element_by_class_name("icon-csv")
driver.execute_script("arguments[0].scrollIntoView();", element)
driver.execute_script("window.scrollBy(0,-100)")
time.sleep(2)# Click on the element to download the file
clicked = element.click()
time.sleep(2)
driver.execute_script("browserstack_executor: {\"action\": \"fileExists\"}")
driver.execute_script("browserstack_executor: {\"action\": \"getFileProperties\"}")
driver.quit()
Did this page help you?
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked