---
title: Handling Permission Popups with Selenium WebDriver
description: How to deal with user-permission dialogs during Automated Selenium testing.
source_url:
  html: https://testingbot.com/support/web-automate/selenium/permission-popups
  md: https://testingbot.com/support/web-automate/selenium/permission-popups/index.md
---
# Handling permission pop-ups

The website you are testing may ask for specific permissions during testing.   
 For example:

- [Permission to access the device location](https://testingbot.com#location)
- [Permission to access the camera and/or microphone](https://testingbot.com#camera)
- [Permission to show notifications](https://testingbot.com#notifications)
- [Permission to access clipboard](https://testingbot.com#clipboard)

The browser might show a popup or prompt, asking for user permission. In case of Automated Testing, you'll need a way to automatically approve/deny these requests. Below we'll show you how to do this with your Automated Tests.

## Location Permission

A popup will appear when the website or mobile app asks the user for the location.   
 You can choose to **Allow** or **Block** this request.

[Java](https://testingbot.com#)[Python](https://testingbot.com#)[NodeJS](https://testingbot.com#)[Ruby](https://testingbot.com#)[PHP](https://testingbot.com#)[C#](https://testingbot.com#)

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    import org.openqa.selenium.remote.RemoteWebDriver;
    
    import java.net.URL;
    import java.util.HashMap;
    import java.util.Map;
    
    public class AllowLocationPopup {
      public static final String URL = "https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub";
    
      public static void main(String[] args) throws Exception {
        ChromeOptions options = new ChromeOptions();
        options.setPlatformName("WIN11");
        options.setBrowserVersion("latest");
    
        Map<String, Object> prefs = new HashMap<>();
        Map<String, Object> profile = new HashMap<>();
        Map<String, Object> contentSettings = new HashMap<>();
    
        // 0 - Default, 1 - Allow, 2 - Block
        contentSettings.put("geolocation", 1);
        profile.put("default_content_setting_values", contentSettings);
        prefs.put("profile", profile);
        options.setExperimentalOption("prefs", prefs);
    
        Map<String, Object> tbOptions = new HashMap<>();
        tbOptions.put("key", "API_KEY");
        tbOptions.put("secret", "API_SECRET");
        options.setCapability("tb:options", tbOptions);
    
        WebDriver driver = new RemoteWebDriver(new URL(URL), options);
        driver.get("https://the-internet.herokuapp.com/geolocation");
        driver.findElement(By.xpath("//*[@id='content']/div/button")).click();
        Thread.sleep(5000);
        driver.quit();
      }
    }

    from time import sleep
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    chrome_options = Options()
    
    # 0 - Default, 1 - Allow, 2 - Block
    chrome_options.add_experimental_option("prefs", { "profile.default_content_setting_values.geolocation": 1})
    
    chrome_options.platform_name = "WIN11"
    chrome_options.browser_version = "latest"
    chrome_options.set_capability("tb:options", {
      "key": "API_KEY",
      "secret": "API_SECRET"
    })
    
    driver = webdriver.Remote(
      command_executor='https://hub.testingbot.com/wd/hub',
      options=chrome_options
    )
    driver.get("https://the-internet.herokuapp.com/geolocation")
    driver.find_element("xpath", "//*[@id='content']/div/button").click()
    sleep(10)
    driver.quit()

    const { Builder, By } = require('selenium-webdriver');
    
    const capabilities = {
      'browserName': 'chrome',
      'browserVersion': 'latest',
      'platformName': 'WIN11',
      'tb:options': {
        'key': 'API_KEY',
        'secret': 'API_SECRET'
      },
      'goog:chromeOptions': {
        prefs: {
          // 0 - Default, 1 - Allow, 2 - Block
          'profile.default_content_setting_values.geolocation': 1
        }
      }
    };
    
    (async function example() {
      const driver = await new Builder()
        .usingServer('https://hub.testingbot.com/wd/hub')
        .withCapabilities(capabilities)
        .build();
    
      await driver.get('https://the-internet.herokuapp.com/geolocation');
      await driver.findElement(By.xpath("//*[@id='content']/div/button")).click();
      await driver.sleep(5000);
      await driver.quit();
    })();

    require 'selenium-webdriver'
    
    options = Selenium::WebDriver::Chrome::Options.new
    options.add_preference("profile.default_content_setting_values.geolocation", 1)
    options.add_option("platformName", "WIN11")
    options.add_option("browserVersion", "latest")
    options.add_option("tb:options", {
      key: "API_KEY",
      secret: "API_SECRET"
    })
    
    driver = Selenium::WebDriver.for :remote,
      url: "https://hub.testingbot.com/wd/hub",
      options: options
    
    driver.navigate.to "https://the-internet.herokuapp.com/geolocation"
    driver.find_element(:xpath, "//*[@id='content']/div/button").click
    sleep 5
    driver.quit

    <?php
    require_once('vendor/autoload.php');
    use Facebook\WebDriver\Remote\RemoteWebDriver;
    use Facebook\WebDriver\WebDriverBy;
    use Facebook\WebDriver\Chrome\ChromeOptions;
    use Facebook\WebDriver\Remote\DesiredCapabilities;
    
    $options = new ChromeOptions();
    // 0 - Default, 1 - Allow, 2 - Block
    $options->setExperimentalOption('prefs', [
        'profile.default_content_setting_values.geolocation' => 1
    ]);
    
    $caps = DesiredCapabilities::chrome();
    $caps->setCapability(ChromeOptions::CAPABILITY, $options);
    $caps->setCapability('platformName', 'WIN11');
    $caps->setCapability('browserVersion', 'latest');
    $caps->setCapability('tb:options', [
        'key' => 'API_KEY',
        'secret' => 'API_SECRET'
    ]);
    
    $driver = RemoteWebDriver::create(
        "https://hub.testingbot.com/wd/hub",
        $caps, 120000
    );
    $driver->get("https://the-internet.herokuapp.com/geolocation");
    $driver->findElement(WebDriverBy::xpath("//*[@id='content']/div/button"))->click();
    sleep(5);
    $driver->quit();
    ?>

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    using OpenQA.Selenium.Remote;
    
    namespace GeoCSharp
    {
        public class Program
        {
            public static void Main(string[] args)
            {
                ChromeOptions options = new ChromeOptions();
                options.PlatformName = "WIN11";
                options.BrowserVersion = "latest";
    
                // 0 - Default, 1 - Allow, 2 - Block
                options.AddUserProfilePreference("profile.default_content_setting_values.geolocation", 1);
    
                var tbOptions = new Dictionary<string, object>
                {
                    ["key"] = "API_KEY",
                    ["secret"] = "API_SECRET"
                };
                options.AddAdditionalOption("tb:options", tbOptions);
    
                IWebDriver driver = new RemoteWebDriver(
                    new Uri("https://hub.testingbot.com/wd/hub"), options);
                driver.Navigate().GoToUrl("https://the-internet.herokuapp.com/geolocation");
                driver.FindElement(By.XPath("//*[@id='content']/div/button")).Click();
                Thread.Sleep(5000);
                driver.Quit();
            }
        }
    }

## Camera and Microphone Permissions

During your Automated Testing, you might want to test and handle Camera and Microphone permissions.

Please see the example below, it shows you how to either **Allow** or **Block** a request from your webapp.

[Java](https://testingbot.com#)[Python](https://testingbot.com#)[NodeJS](https://testingbot.com#)[Ruby](https://testingbot.com#)[PHP](https://testingbot.com#)[C#](https://testingbot.com#)

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    import org.openqa.selenium.remote.RemoteWebDriver;
    
    import java.net.URL;
    import java.util.HashMap;
    import java.util.Map;
    
    public class AllowCameraPopupChrome {
      public static final String URL = "https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub";
    
      public static void main(String[] args) throws Exception {
        // Configure ChromeOptions to pass a fake media stream
        ChromeOptions options = new ChromeOptions();
        options.addArguments("use-fake-device-for-media-stream");
        options.addArguments("use-fake-ui-for-media-stream");
        options.setPlatformName("WIN11");
        options.setBrowserVersion("latest");
    
        Map<String, Object> tbOptions = new HashMap<>();
        tbOptions.put("key", "API_KEY");
        tbOptions.put("secret", "API_SECRET");
        options.setCapability("tb:options", tbOptions);
    
        WebDriver driver = new RemoteWebDriver(new URL(URL), options);
    
        // WebCam Test
        driver.get("https://webcamtests.com/check");
        Thread.sleep(5000);
        driver.findElement(By.id("webcam-launcher")).click();
        Thread.sleep(2000);
    
        // Microphone Test
        driver.get("https://www.vidyard.com/mic-test/");
        Thread.sleep(2000);
        driver.findElement(By.xpath("//a[@id='start-test']")).click();
        Thread.sleep(2000);
    
        driver.quit();
      }
    }

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.chrome.options import Options
    import time
    
    # Configure ChromeOptions to pass fake media stream
    chrome_options = Options()
    chrome_options.add_argument("--use-fake-device-for-media-stream")
    chrome_options.add_argument("--use-fake-ui-for-media-stream")
    chrome_options.platform_name = "WIN11"
    chrome_options.browser_version = "latest"
    chrome_options.set_capability("tb:options", {
      "key": "API_KEY",
      "secret": "API_SECRET"
    })
    
    driver = webdriver.Remote(
      command_executor='https://hub.testingbot.com/wd/hub',
      options=chrome_options
    )
    
    # WebCam Test
    driver.get("https://webcamtests.com/check")
    time.sleep(5)
    driver.find_element(By.ID, "webcam-launcher").click()
    time.sleep(2)
    
    # Mic Test
    driver.get("https://www.vidyard.com/mic-test/")
    time.sleep(5)
    driver.find_element(By.XPATH, "//a[@id='start-test']").click()
    time.sleep(2)
    driver.quit()

    const { Builder, By } = require('selenium-webdriver');
    
    const capabilities = {
      'browserName': 'chrome',
      'browserVersion': 'latest',
      'platformName': 'WIN11',
      'tb:options': {
        'key': 'API_KEY',
        'secret': 'API_SECRET'
      },
      // Configure ChromeOptions to pass fake media stream
      'goog:chromeOptions': {
        'args': ['--use-fake-device-for-media-stream', '--use-fake-ui-for-media-stream']
      }
    };
    
    (async function example() {
      const driver = await new Builder()
        .usingServer('https://hub.testingbot.com/wd/hub')
        .withCapabilities(capabilities)
        .build();
    
      // Webcam Test
      await driver.get('https://webcamtests.com/check');
      await driver.sleep(5000);
      await driver.findElement(By.id('webcam-launcher')).click();
      await driver.sleep(2000);
    
      // Microphone Test
      await driver.get('https://www.vidyard.com/mic-test/');
      await driver.sleep(2000);
      await driver.findElement(By.xpath("//a[@id='start-test']")).click();
      await driver.sleep(2000);
    
      await driver.quit();
    })();

    require 'selenium-webdriver'
    
    # Configure ChromeOptions to pass a fake media stream during testing
    options = Selenium::WebDriver::Chrome::Options.new
    options.add_argument('--use-fake-device-for-media-stream')
    options.add_argument('--use-fake-ui-for-media-stream')
    options.add_option("platformName", "WIN11")
    options.add_option("browserVersion", "latest")
    options.add_option("tb:options", {
      key: "API_KEY",
      secret: "API_SECRET"
    })
    
    driver = Selenium::WebDriver.for :remote,
      url: "https://hub.testingbot.com/wd/hub",
      options: options
    
    # Web Cam Test
    driver.navigate.to "https://webcamtests.com/check"
    sleep(5)
    driver.find_element(:id, "webcam-launcher").click
    sleep(2)
    
    # Microphone Test
    driver.navigate.to "https://www.vidyard.com/mic-test/"
    sleep(5)
    driver.find_element(:xpath, "//a[@id='start-test']").click
    sleep(2)
    driver.quit

    <?php
    require_once('vendor/autoload.php');
    use Facebook\WebDriver\Remote\RemoteWebDriver;
    use Facebook\WebDriver\WebDriverBy;
    use Facebook\WebDriver\Chrome\ChromeOptions;
    use Facebook\WebDriver\Remote\DesiredCapabilities;
    
    $options = new ChromeOptions();
    $options->addArguments(['--use-fake-device-for-media-stream', '--use-fake-ui-for-media-stream']);
    
    $caps = DesiredCapabilities::chrome();
    $caps->setCapability(ChromeOptions::CAPABILITY, $options);
    $caps->setCapability('platformName', 'WIN11');
    $caps->setCapability('browserVersion', 'latest');
    $caps->setCapability('tb:options', [
        'key' => 'API_KEY',
        'secret' => 'API_SECRET'
    ]);
    
    $driver = RemoteWebDriver::create(
        "https://hub.testingbot.com/wd/hub",
        $caps, 120000
    );
    
    // WebCam Test
    $driver->get("https://webcamtests.com/check");
    sleep(5);
    $driver->findElement(WebDriverBy::id("webcam-launcher"))->click();
    sleep(2);
    
    // Microphone Test
    $driver->get("https://www.vidyard.com/mic-test/");
    sleep(5);
    $driver->findElement(WebDriverBy::xpath("//a[@id='start-test']"))->click();
    sleep(2);
    
    $driver->quit();
    ?>

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    using OpenQA.Selenium.Remote;
    
    namespace SampleCSharp
    {
        public class AllowCameraMicPopupChrome
        {
            static void Main(string[] args)
            {
                // Configure ChromeOptions to pass fake media stream
                ChromeOptions options = new ChromeOptions();
                options.AddArgument("--use-fake-device-for-media-stream");
                options.AddArgument("--use-fake-ui-for-media-stream");
                options.PlatformName = "WIN11";
                options.BrowserVersion = "latest";
    
                var tbOptions = new Dictionary<string, object>
                {
                    ["key"] = "API_KEY",
                    ["secret"] = "API_SECRET"
                };
                options.AddAdditionalOption("tb:options", tbOptions);
    
                IWebDriver driver = new RemoteWebDriver(
                    new Uri("https://hub.testingbot.com/wd/hub"), options);
    
                // Webcam Test
                driver.Navigate().GoToUrl("https://webcamtests.com/check");
                Thread.Sleep(5000);
                driver.FindElement(By.Id("webcam-launcher")).Click();
                Thread.Sleep(2000);
    
                // Microphone Test
                driver.Navigate().GoToUrl("https://www.vidyard.com/mic-test/");
                Thread.Sleep(2000);
                driver.FindElement(By.XPath("//a[@id='start-test']")).Click();
                Thread.Sleep(2000);
    
                driver.Quit();
            }
        }
    }

## Notification Permissions

During your Automated Testing, the website might request access to show notifications.

Please see the example below, it shows you how to either **Allow** or **Block** a notification request.

[Java](https://testingbot.com#)[Python](https://testingbot.com#)[NodeJS](https://testingbot.com#)[Ruby](https://testingbot.com#)[PHP](https://testingbot.com#)[C#](https://testingbot.com#)

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    import org.openqa.selenium.remote.RemoteWebDriver;
    
    import java.net.URL;
    import java.util.HashMap;
    import java.util.Map;
    
    public class AllowNotificationPopupDesktop {
      public static final String URL = "https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub";
    
      public static void main(String[] args) throws Exception {
        ChromeOptions options = new ChromeOptions();
        options.setPlatformName("WIN11");
        options.setBrowserVersion("latest");
    
        Map<String, Object> prefs = new HashMap<>();
        Map<String, Object> profile = new HashMap<>();
        Map<String, Object> contentSettings = new HashMap<>();
    
        // 0 - Default, 1 - Allow, 2 - Block
        contentSettings.put("notifications", 1);
        profile.put("default_content_setting_values", contentSettings);
        prefs.put("profile", profile);
        options.setExperimentalOption("prefs", prefs);
    
        Map<String, Object> tbOptions = new HashMap<>();
        tbOptions.put("key", "API_KEY");
        tbOptions.put("secret", "API_SECRET");
        options.setCapability("tb:options", tbOptions);
    
        WebDriver driver = new RemoteWebDriver(new URL(URL), options);
    
        driver.get("https://web-push-book.gauntface.com/demos/notification-examples/");
        driver.findElement(By.xpath("//body/main[1]/p[3]/input[1]")).click();
        Thread.sleep(2000);
        driver.quit();
      }
    }

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.chrome.options import Options
    import time
    
    # 0 - Default, 1 - Allow, 2 - Block
    chrome_options = Options()
    chrome_options.add_experimental_option("prefs", {
      "profile.default_content_setting_values.notifications": 1
    })
    chrome_options.platform_name = "WIN11"
    chrome_options.browser_version = "latest"
    chrome_options.set_capability("tb:options", {
      "key": "API_KEY",
      "secret": "API_SECRET"
    })
    
    driver = webdriver.Remote(
      command_executor='https://hub.testingbot.com/wd/hub',
      options=chrome_options
    )
    driver.get("https://web-push-book.gauntface.com/demos/notification-examples/")
    driver.find_element(By.XPATH, "//body/main[1]/p[3]/input[1]").click()
    time.sleep(2)
    driver.quit()

    const { Builder, By } = require('selenium-webdriver');
    
    const capabilities = {
      'browserName': 'chrome',
      'browserVersion': 'latest',
      'platformName': 'WIN11',
      'tb:options': {
        'key': 'API_KEY',
        'secret': 'API_SECRET'
      },
      'goog:chromeOptions': {
        prefs: {
          // 0 - Default, 1 - Allow, 2 - Block
          'profile.default_content_setting_values.notifications': 1
        }
      }
    };
    
    (async function example() {
      const driver = await new Builder()
        .usingServer('https://hub.testingbot.com/wd/hub')
        .withCapabilities(capabilities)
        .build();
    
      await driver.get('https://web-push-book.gauntface.com/demos/notification-examples/');
      await driver.findElement(By.xpath("//body/main[1]/p[3]/input[1]")).click();
      await driver.sleep(2000);
      await driver.quit();
    })();

    require 'selenium-webdriver'
    
    # 0 - Default, 1 - Allow, 2 - Block
    options = Selenium::WebDriver::Chrome::Options.new
    options.add_preference("profile.default_content_setting_values.notifications", 1)
    options.add_option("platformName", "WIN11")
    options.add_option("browserVersion", "latest")
    options.add_option("tb:options", {
      key: "API_KEY",
      secret: "API_SECRET"
    })
    
    driver = Selenium::WebDriver.for :remote,
      url: "https://hub.testingbot.com/wd/hub",
      options: options
    
    driver.navigate.to "https://web-push-book.gauntface.com/demos/notification-examples/"
    driver.find_element(:xpath, "//body/main[1]/p[3]/input[1]").click
    sleep(2)
    driver.quit

    <?php
    require_once('vendor/autoload.php');
    use Facebook\WebDriver\Remote\RemoteWebDriver;
    use Facebook\WebDriver\WebDriverBy;
    use Facebook\WebDriver\Chrome\ChromeOptions;
    use Facebook\WebDriver\Remote\DesiredCapabilities;
    
    $options = new ChromeOptions();
    // 0 - Default, 1 - Allow, 2 - Block
    $options->setExperimentalOption('prefs', [
        'profile.default_content_setting_values.notifications' => 1
    ]);
    
    $caps = DesiredCapabilities::chrome();
    $caps->setCapability(ChromeOptions::CAPABILITY, $options);
    $caps->setCapability('platformName', 'WIN11');
    $caps->setCapability('browserVersion', 'latest');
    $caps->setCapability('tb:options', [
        'key' => 'API_KEY',
        'secret' => 'API_SECRET'
    ]);
    
    $driver = RemoteWebDriver::create(
        "https://hub.testingbot.com/wd/hub",
        $caps, 120000
    );
    $driver->get("https://web-push-book.gauntface.com/demos/notification-examples/");
    $driver->findElement(WebDriverBy::xpath("//body/main[1]/p[3]/input[1]"))->click();
    sleep(2);
    $driver->quit();
    ?>

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    using OpenQA.Selenium.Remote;
    
    namespace SampleCSharp
    {
        public class Program
        {
            static void Main(string[] args)
            {
                ChromeOptions options = new ChromeOptions();
                options.PlatformName = "WIN11";
                options.BrowserVersion = "latest";
    
                // 0 - Default, 1 - Allow, 2 - Block
                options.AddUserProfilePreference("profile.default_content_setting_values.notifications", 1);
    
                var tbOptions = new Dictionary<string, object>
                {
                    ["key"] = "API_KEY",
                    ["secret"] = "API_SECRET"
                };
                options.AddAdditionalOption("tb:options", tbOptions);
    
                IWebDriver driver = new RemoteWebDriver(
                    new Uri("https://hub.testingbot.com/wd/hub"), options);
                driver.Navigate().GoToUrl("https://web-push-book.gauntface.com/demos/notification-examples/");
                driver.FindElement(By.XPath("//body/main[1]/p[3]/input[1]")).Click();
                Thread.Sleep(2000);
                driver.Quit();
            }
        }
    }

## Clipboard Permissions

During your Automated Testing, Javascript code on the website you are testing might ask for clipboard permission.   
 This permission dialog asks the user if the website can read (and/or write) to the clipboard.

 ![Clipboard Access Request example](https://testingbot.com/assets/support/clipboard-permission-d786d434b15e680ce09b16d2655082be94f712a638ccba2394051f7cdc6cc962.webp)

Usually, this is accomplished by running a piece of Javascript code, similar to this snippet:

    const text = await navigator.clipboard.readText();

Please see the example below, it shows you how to either **Allow** or **Block** a clipboard access request.

[Java](https://testingbot.com#)[Python](https://testingbot.com#)[NodeJS](https://testingbot.com#)[Ruby](https://testingbot.com#)[PHP](https://testingbot.com#)[C#](https://testingbot.com#)

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    import org.openqa.selenium.remote.RemoteWebDriver;
    
    import java.net.URL;
    import java.util.HashMap;
    import java.util.Map;
    
    public class AllowClipboardPermission {
      public static final String URL = "https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub";
    
      private static Map<String, Object> getClipBoardSettingsMap(int settingValue) {
        Map<String, Object> map = new HashMap<>();
        map.put("last_modified", String.valueOf(System.currentTimeMillis()));
        map.put("setting", settingValue);
        Map<String, Object> cbPreference = new HashMap<>();
        cbPreference.put("[*.],*", map);
        return cbPreference;
      }
    
      public static void main(String[] args) throws Exception {
        ChromeOptions options = new ChromeOptions();
        options.setPlatformName("WIN11");
        options.setBrowserVersion("latest");
    
        Map<String, Object> prefs = new HashMap<>();
        prefs.put("profile.content_settings.exceptions.clipboard", getClipBoardSettingsMap(1));
        options.setExperimentalOption("prefs", prefs);
    
        Map<String, Object> tbOptions = new HashMap<>();
        tbOptions.put("key", "API_KEY");
        tbOptions.put("secret", "API_SECRET");
        options.setCapability("tb:options", tbOptions);
    
        WebDriver driver = new RemoteWebDriver(new URL(URL), options);
    
        driver.get("https://permission.site/#read-text");
        driver.findElement(By.id("read-text")).click();
        Thread.sleep(2000);
        driver.quit();
      }
    }

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.chrome.options import Options
    import time
    
    chrome_options = Options()
    chrome_options.add_experimental_option('prefs', {
      'profile.content_settings.exceptions.clipboard': {
        '*': {'setting': 1}
      }
    })
    chrome_options.platform_name = "WIN11"
    chrome_options.browser_version = "latest"
    chrome_options.set_capability("tb:options", {
      "key": "API_KEY",
      "secret": "API_SECRET"
    })
    
    driver = webdriver.Remote(
      command_executor='https://hub.testingbot.com/wd/hub',
      options=chrome_options
    )
    driver.get("https://permission.site/#read-text")
    driver.find_element(By.ID, "read-text").click()
    time.sleep(2)
    driver.quit()

    const { Builder, By } = require('selenium-webdriver');
    const chrome = require('selenium-webdriver/chrome');
    
    const chromeOptions = new chrome.Options();
    chromeOptions.setUserPreferences({
      profile: {
        content_settings: {
          exceptions: {
            clipboard: {
              'https://permission.site,*': {
                expiration: '0',
                last_modified: Date.now().toString(),
                model: 0,
                setting: 1
              }
            }
          }
        }
      }
    });
    
    const capabilities = {
      'browserName': 'chrome',
      'browserVersion': 'latest',
      'platformName': 'WIN11',
      'tb:options': {
        'key': 'API_KEY',
        'secret': 'API_SECRET'
      }
    };
    
    (async function example() {
      const driver = await new Builder()
        .usingServer('https://hub.testingbot.com/wd/hub')
        .withCapabilities(capabilities)
        .setChromeOptions(chromeOptions)
        .build();
    
      await driver.get('https://permission.site/#read-text');
      await driver.findElement(By.id('read-text')).click();
      await driver.sleep(2000);
      await driver.quit();
    })();

    require 'selenium-webdriver'
    
    options = Selenium::WebDriver::Chrome::Options.new
    options.add_preference("profile.content_settings.exceptions.clipboard", {
      '*' => { 'setting' => 1 }
    })
    options.add_option("platformName", "WIN11")
    options.add_option("browserVersion", "latest")
    options.add_option("tb:options", {
      key: "API_KEY",
      secret: "API_SECRET"
    })
    
    driver = Selenium::WebDriver.for :remote,
      url: "https://hub.testingbot.com/wd/hub",
      options: options
    
    driver.navigate.to "https://permission.site/#read-text"
    driver.find_element(:id, "read-text").click
    sleep(2)
    driver.quit

    <?php
    require_once('vendor/autoload.php');
    use Facebook\WebDriver\Remote\RemoteWebDriver;
    use Facebook\WebDriver\WebDriverBy;
    use Facebook\WebDriver\Chrome\ChromeOptions;
    use Facebook\WebDriver\Remote\DesiredCapabilities;
    
    $options = new ChromeOptions();
    $options->setExperimentalOption('prefs', [
        'profile.content_settings.exceptions.clipboard' => [
            '*' => ['setting' => 1]
        ]
    ]);
    
    $caps = DesiredCapabilities::chrome();
    $caps->setCapability(ChromeOptions::CAPABILITY, $options);
    $caps->setCapability('platformName', 'WIN11');
    $caps->setCapability('browserVersion', 'latest');
    $caps->setCapability('tb:options', [
        'key' => 'API_KEY',
        'secret' => 'API_SECRET'
    ]);
    
    $driver = RemoteWebDriver::create(
        "https://hub.testingbot.com/wd/hub",
        $caps, 120000
    );
    $driver->get("https://permission.site/#read-text");
    $driver->findElement(WebDriverBy::id("read-text"))->click();
    sleep(2);
    $driver->quit();
    ?>

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    using OpenQA.Selenium.Remote;
    
    namespace SampleCSharp
    {
        public class Program
        {
            static void Main(string[] args)
            {
                ChromeOptions options = new ChromeOptions();
                options.PlatformName = "WIN11";
                options.BrowserVersion = "latest";
    
                var clipboardException = new Dictionary<string, object>
                {
                    ["[*.]permission.site,*"] = new Dictionary<string, object>
                    {
                        ["last_modified"] = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
                        ["setting"] = 1
                    }
                };
                options.AddUserProfilePreference("profile.content_settings.exceptions.clipboard", clipboardException);
    
                var tbOptions = new Dictionary<string, object>
                {
                    ["key"] = "API_KEY",
                    ["secret"] = "API_SECRET"
                };
                options.AddAdditionalOption("tb:options", tbOptions);
    
                IWebDriver driver = new RemoteWebDriver(
                    new Uri("https://hub.testingbot.com/wd/hub"), options);
                driver.Navigate().GoToUrl("https://permission.site/#read-text");
                driver.FindElement(By.Id("read-text")).Click();
                Thread.Sleep(2000);
                driver.Quit();
            }
        }
    }

Was this page helpful? Yes No 

## Looking for More Help?

Have questions or need more information?   
 You can reach us via the following channels:

- [Email us](https://testingbot.com/contact/new)
- [Join our Slack Channel](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
