Disable Flash
Learn how to disable Flash for your Selenium tests on BrowserStack Automate.
You can disable Flash for various browsers including Chrome, IE and Firefox. This guide provides code samples and solutions to disable Flash when testing your application.
If you are using BrowserStack SDK, you can set the following capabilities in the browserstack.yml
file:
Disable Flash in Chrome
To disable Flash in Chrome, pass the --disable-plugins
argument under the chromeOptions
capability.
Using this argument will turn off all the plugins in the browser.
Use the following sample code snippets to disable Flash in Chrome .
```yml
platforms:
- os: OS X
osVersion: Big Sur
browserName: Chrome
browserVersion: latest
chrome:
driver: 112.0.5615.28
chromeOptions:
args:
- --disable-plugins
```
Copy icon
Copy
platforms :
- os : OS X
osVersion : Big Sur
browserName : Chrome
browserVersion : latest
chrome :
driver : 112.0.5615.28
chromeOptions :
args :
- - - disable- plugins
Disable Flash in IE
To disable Flash in IE, pass the browserstack.ie.noFlash
capability in your tests.
Use the following sample code snippets to disable Flash in IE .
```yml
platforms:
- os: Windows
osVersion: 10
browserName: IE
browserVersion: 11.0
ie:
driver: 4.0.0
noFlash: true
```
Copy icon
Copy
platforms :
- os : Windows
osVersion : 10
browserName : IE
browserVersion : 11.0
ie :
driver : 4.0.0
noFlash : true
Disable Flash in Firefox
To disable Flash in Firefox, use the legacy integration method.
BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page .
Disable Flash in Chrome
DesiredCapabilities capabilities = new DesiredCapabilities ( ) ;
HashMap < String , Object > browserstackOptions = new HashMap < String , Object > ( ) ;
ChromeOptions options = new ChromeOptions ( ) ;
browserstackOptions. addArguments ( "--disable-plugins" ) ;
capabilities. setCapability ( "bstack:options" , browserstackOptions) ;
Copy icon
Copy
var capabilities = {
'bstack:options' : {
"chromeOptions" : {
args: [ '--disable-plugins' ] ,
} ,
"browserName" : "Chrome" ,
}
}
Copy icon
Copy
using OpenQA. Selenium. Chrome ;
ChromeOptions capabilities = new ChromeOptions ( ) ;
Dictionary< string , object > browserstackOptions = new Dictionary< string , object > ( ) ;
browserstackOptions. AddArgument ( "--disable-plugins" ) ;
capabilities. AddAdditionalOption ( "bstack:options" , browserstackOptions) ;
Copy icon
Copy
$chromeOptions = array (
"args" => array ( '--disable-plugins' )
) ;
$caps = array (
'bstack:options' => array (
"os" => "Windows" ,
"chromeOptions" => $chromeOptions ) ,
"browserName" => "Chrome" ,
)
Copy icon
Copy
caps = {
'bstack:options' : {
"ChromeOptions" : {
"args" : [ "--disable-plugins" ]
}
}
}
Copy icon
Copy
capabilities = {
'bstack:options' = > {
"ChromeOptions" = > {
"args" = > [ "--disable-plugins" ]
} ,
}
}
Copy icon
Copy
ChromeOptions options = new ChromeOptions ( ) ;
options. addArguments ( "--disable-plugins" ) ;
caps. setCapability ( ChromeOptions . CAPABILITY, options) ;
Copy icon
Copy
var capabilities = {
browserName: 'chrome' ,
chromeOptions: {
args: [ '--disable-plugins' ] ,
} ,
} ;
Copy icon
Copy
using OpenQA. Selenium. Chrome ;
DesiredCapabilities caps;
ChromeOptions chromeOptions = new ChromeOptions ( ) ;
chromeOptions. AddArgument ( "--disable-plugins" ) ;
caps = ( DesiredCapabilities) chromeOptions. ToCapabilities ( ) ;
Copy icon
Copy
$chromeOptions = array ( 'args' => array ( '--disable-plugins' ) ) ;
$caps = array ( "platform" => "WINDOWS" , "browserName" => "chrome" , "chromeOptions" => $chromeOptions ) ;
Copy icon
Copy
caps = DesiredCapabilities. CHROME
caps[ "chromeOptions" ] = { }
caps[ "chromeOptions" ] [ "args" ] = [ "--disable-plugins" ]
Copy icon
Copy
caps = Selenium : : WebDriver : : Remote : : Capabilities . chrome
caps[ "chromeOptions" ] = { }
caps[ "chromeOptions" ] [ "args" ] = [ "--disable-plugins" ]
Copy icon
Copy
Disable Flash in IE
To disable Flash in IE, pass the browserstack.ie.noFlash
capability in your tests.
Use the following sample code snippets to disable Flash in IE .
DesiredCapabilities capabilities = new DesiredCapabilities ( ) ;
HashMap < String , Object > browserstackOptions = new HashMap < String , Object > ( ) ;
browserstackOptions. put ( "browserstack.ie.noFlash" , "true" ) ;
capabilities. setCapability ( "bstack:options" , browserstackOptions) ;
Copy icon
Copy
var capabilities = {
'bstack:options' : {
"browserstack.ie.noFlash" : "true" ,
} ,
"browserName" : "Edge" ,
}
Copy icon
Copy
EdgeOptions capabilities = new EdgeOptions ( ) ;
Dictionary< string , object > browserstackOptions = new Dictionary< string , object > ( ) ;
browserstackOptions. Add ( "browserstack.ie.noFlash" , "true" ) ) ;
capabilities. AddAdditionalOption ( "bstack:options" , browserstackOptions) ;
Copy icon
Copy
$caps = array (
'bstack:options' => array (
"browserstack.ie.noFlash" => "true" ,
) ,
"browserName" => "Edge" ,
)
Copy icon
Copy
caps = {
'bstack:options' : {
"browserstack.ie.noFlash" : "true" ,
} ,
"browserName" : "Edge" ,
}
Copy icon
Copy
capabilities = {
'bstack:options' = > {
"browserstack.ie.noFlash" = > "true" ,
} ,
"browserName" = > "Edge" ,
}
Copy icon
Copy
DesiredCapabilities caps = new DesiredCapabilities ( ) ;
caps. setCapability ( "browserstack.ie.noFlash" , "true" ) ;
Copy icon
Copy
var capabilities = {
'browserstack.ie.noFlash' : 'true' ,
} ;
Copy icon
Copy
desiredCap. SetCapability ( "browserstack.ie.noFlash" , "true" ) ;
Copy icon
Copy
$caps [ 'browserstack.ie.noFlash' ] = "true" ;
Copy icon
Copy
desired_cap[ "browserstack.ie.noFlash" ] = "true"
Copy icon
Copy
caps[ "browserstack.ie.noFlash" ] = "true"
Copy icon
Copy
Disable Flash in Firefox
Set the flash
capability to 0
to disable Flash in Firefox.
Use the following sample code snippets to disable Flash in Firefox .
import org. openqa. selenium. firefox. FirefoxProfile ;
FirefoxProfile profile = new FirefoxProfile ( ) ;
profile. setPreference ( "plugin.state.flash" , 0 ) ;
DesiredCapabilities capabilities = new DesiredCapabilities ( ) ;
HashMap < String , Object > browserstackOptions = new HashMap < String , Object > ( ) ;
capabilities. setCapability ( "bstack:options" , browserstackOptions) ;
capabilities. setCapability ( FirefoxDriver . PROFILE, profile) ;
Copy icon
Copy
npm install firefox- profile
const firefox = require ( 'selenium-webdriver/firefox' )
let profile = new firefox. Options ( ) ;
profile. setPreference ( "plugin.state.flash" , 0 ) ;
profile. updatePreferences ( ) ;
Copy icon
Copy
using OpenQA. Selenium. Firefox ;
FirefoxOptions capabilities = new FirefoxOptions ( ) ;
Dictionary< string , object > browserstackOptions = new Dictionary< string , object > ( ) ;
capabilities. SetPreference ( "plugin.state.flash" , 0 ) ;
capabilities. AddAdditionalOption ( "bstack:options" browserstackOptions) ;
Copy icon
Copy
$profile = new FirefoxProfile ( ) ;
$profile -> setPreference (
'plugin.state.flash' , 0
) ;
$caps = array (
'bstack:options' => array (
"firefoxProfile" => $profile ) ,
)
Copy icon
Copy
from selenium import webdriver
from selenium. webdriver. firefox. options import Options as FirefoxOptions
options = FirefoxOptions( )
options. set_preference( 'plugin.state.flash' , 0 )
driver = webdriver. Remote(
command_executor= 'https://hub.browserstack.com/wd/hub' ,
options= options)
Copy icon
Copy
require 'rubygems'
require 'selenium-webdriver'
options = Selenium : : WebDriver : : Firefox : : Options . new
options. add_preference( 'plugin.state.flash' , 0 )
Copy icon
Copy
FirefoxProfile profile = new FirefoxProfile ( ) ;
profile. setPreference ( "plugin.state.flash" , 0 ) ;
caps. setCapability ( FirefoxDriver . PROFILE, profile) ;
Copy icon
Copy
npm install firefox- profile
var myProfile = new FirefoxProfile ( ) ;
myProfile. setPreference ( "plugin.state.flash" , 0 ) ;
myProfile. updatePreferences ( ) ;
Copy icon
Copy
using OpenQA. Selenium. Firefox ;
FirefoxProfile firefoxProfile = new FirefoxProfile ( ) ;
DesiredCapabilities caps = DesiredCapabilities. Firefox ( ) ;
firefoxProfile. SetPreference ( "plugin.state.flash" , 0 ) ;
caps. SetCapability ( FirefoxDriver. ProfileCapabilityName, firefoxProfile. ToBase64String ( ) ) ;
Copy icon
Copy
$profile = new FirefoxProfile ( ) ;
$profile -> setPreference (
'plugin.state.flash' , 0
) ;
$caps = DesiredCapabilities :: firefox ( ) ;
$caps -> setCapability ( FirefoxDriver :: PROFILE , $profile ) ;
Copy icon
Copy
caps = DesiredCapabilities. FIREFOX
profile = webdriver. FirefoxProfile( )
profile. set_preference( 'plugin.state.flash' , 0 )
profile. update_preferences( )
driver = webdriver. Remote(
command_executor= 'https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub' ,
desired_capabilities= caps, browser_profile= profile)
Copy icon
Copy
profile = Selenium : : WebDriver : : Firefox : : Profile . new
profile[ "plugin.state.flash" ] = 0
caps = Selenium : : WebDriver : : Remote : : Capabilities . firefox( :firefox_profile = > profile)
Copy icon
Copy
Is this page helping you?
Thank you for your valuable feedback!