Features

Handling permission pop-ups

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

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.

Copy code
require 'rubygems'
require 'selenium-webdriver'

# 0 - Default, 1 - Allow, 2 - Block
caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"prefs" => { "profile.default_content_setting_values.geolocation" => 1 } })

caps['browserName'] = 'Chrome'
caps['version'] = 'latest'
caps['platform'] = 'WIN10'

driver = Selenium::WebDriver.for(:remote,
  :url => "https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub",
  :desired_capabilities => caps)
driver.navigate.to "https://the-internet.herokuapp.com/geolocation"
driver.find_element(:xpath, "//*[@id='content']/div/button").click;
sleep 5
driver.quit
Copy code
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
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 {
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("browserName", "Chrome");
    caps.setCapability("version", "latest");
    caps.setCapability("platform", "WIN10");

    ChromeOptions options = new ChromeOptions();
    Map<String, Object> prefs = new HashMap<String, Object>();
    Map<String, Object> profile = new HashMap<String, Object>();
    Map<String, Object> contentSettings = new HashMap<String, Object>();

    // 0 - Default, 1 - Allow, 2 - Block
    contentSettings.put("geolocation", 1);
    profile.put("managed_default_content_settings", contentSettings);
    prefs.put("profile", profile);
    options.setExperimentalOption("prefs", prefs);

    caps.setCapability(ChromeOptions.CAPABILITY, options);
    WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
    driver.get("https://the-internet.herokuapp.com/geolocation");
    driver.findElement(By.xpath("//*[@id='content']/div/button")).click();
    Thread.sleep(5000);
    driver.quit();
  }
}
Copy code
<?php

    require_once('vendor/autoload.php');
    use Facebook\WebDriver\Remote\RemoteWebDriver;
    use Facebook\WebDriver\WebDriverBy;

    $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_W3C,
        // There is a bug in php-webdriver, so ->toArray() is needed!
        $options->toArray()
    );
    $web_driver = RemoteWebDriver::create(
    "https://api_key:api_secret@hub.testingbot.com/wd/hub",
      $caps, 120000
    );
    $web_driver->get("https://google.com");

    $element = $web_driver->findElement(WebDriverBy::name("q"));
    if ($element) {
      $element->sendKeys("TestingBot");
      $element->submit();
    }
    print $web_driver->getTitle();
    $web_driver->quit();
?>
Copy code
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
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})

desired_cap = chrome_options.to_capabilities()
desired_cap.update({
  'version': 'latest',
  'platform': 'WIN10',
  'browserName': 'chrome'
})

driver = webdriver.Remote(command_executor='https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub', desired_capabilities=desired_cap)
driver.get("https://the-internet.herokuapp.com/geolocation")
driver.find_element_by_xpath("//*[@id='content']/div/button").click()
sleep(10)
driver.quit()
Copy code
const chrome = require("selenium-webdriver/chrome");

const capabilities = {
  'browserName' : 'Chrome',
  'version' : 'latest',
  'platform' : 'WIN10'

  'goog:chromeOptions': {
    prefs: {
      // 0 - Default, 1 - Allow this permission request, 2 - Block (deny) this permission request
      'profile.managed_default_content_settings.geolocation' : 1
    }
  }
}

const driver = new webdriver.Builder()
  .usingServer('https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub')
  .withCapabilities(capabilities)
  .build();

driver.get('https://the-internet.herokuapp.com/geolocation')
  .then(function(){
    driver.findElement(webdriver.By.xpath("//*[@id='content']/div/button")).click()
      .then(function(){
        driver.quit();
      });
  });
Copy code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Remote;

namespace GeoCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            RemoteWebDriver driver;
            Dictionary<string, object> profile = new Dictionary<string, object>();

            // 0 - Default, 1 - Allow, 2 - Block
            profile.Add("profile.default_content_setting_values.geolocation", 1);

            Dictionary<string, object> chromeOptions = new Dictionary<string, object>();

            chromeOptions.Add("prefs", profile);

            ChromeOptions capability = new ChromeOptions();
            capability.AddAdditionalCapability("browserName", "Chrome", true);
            capability.AddAdditionalCapability("version", "latest", true);
            capability.AddAdditionalCapability("platform", "WIN10", true);
            capability.AddAdditionalCapability("key", "key", true);
            capability.AddAdditionalCapability("secret", "secret", true);
            capability.AddAdditionalCapability("chromeOptions", chromeOptions, true);

            driver = new RemoteWebDriver(new Uri("http://hub.testingbot.com/wd/hub/"), capability);
            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.

Copy code
require 'rubygems'
require 'selenium-webdriver'

# Configure ChromeOptions to pass a fake media stream during testing
# You can use this with Edge as well
caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => ['--use-fake-device-for-media-stream', '--use-fake-ui-for-media-stream'] })
caps['browserName'] = 'Chrome'
caps['version'] = 'latest'
caps['platform'] = 'WIN10'

driver = Selenium::WebDriver.for(:remote,
  :url => "https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub",
  :desired_capabilities => caps)

# 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
Copy code
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.net.URL;

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");

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("browserName", "Chrome");
    caps.setCapability("version", "latest");
    caps.setCapability("platform", "WIN10");
    caps.setCapability(ChromeOptions.CAPABILITY, options);
    WebDriver driver = new RemoteWebDriver(new URL(URL), caps);

    // 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();
  }
}
Copy code
<?php

    require_once('vendor/autoload.php');
    use Facebook\WebDriver\Remote\RemoteWebDriver;
    use Facebook\WebDriver\WebDriverBy;

    $options = new ChromeOptions();
    $options->addArguments(array("use-fake-device-for-media-stream", "use-fake-ui-for-media-stream"));
    $caps = DesiredCapabilities::chrome();

    $caps->setCapability(
        ChromeOptions::CAPABILITY,
        $options
    );
    $web_driver = RemoteWebDriver::create(
    "https://api_key:api_secret@hub.testingbot.com/wd/hub",
      $caps, 120000
    );
    
    // WebCam Test
    $web_driver->get("https://webcamtests.com/check");
    $element = $web_driver->findElement(WebDriverBy::id("webcam-launcher"));
    if ($element) {
      $element->click();
    }

    // Microphone Test
    $web_driver->get("https://www.vidyard.com/mic-test");
    $element = $web_driver->findElement(WebDriverBy::xpath("(//a[@id='start-test']")));
    if ($element) {
      $element->click();
    }

    $web_driver->quit();
?>
Copy code
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
import time

desired_cap = {
  'version': 'latest',
  'platform': 'WIN10',
  'browserName': 'chrome'

  # Configure ChromeOptions to pass fake media stream
  'chromeOptions': {
    'args': ["--use-fake-device-for-media-stream", "--use-fake-ui-for-media-stream"]
  }
}
driver = webdriver.Remote(command_executor='https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub', desired_capabilities=desired_cap)

# 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()
Copy code
const webdriver = require('selenium-webdriver');
const chrome = require("selenium-webdriver/chrome");

const capabilities = {
  'browserName' : 'Chrome',
  'version' : 'latest',
  'platform' : 'WIN10',

  // Configure ChromeOptions to pass fake media stream
  'goog:chromeOptions': {
    'args': ["--use-fake-device-for-media-stream", "--use-fake-ui-for-media-stream"]
  }
}

const driver = new webdriver.Builder()
  .usingServer('https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub')
  .withCapabilities(capabilities)
  .build();

// Webcam Test
driver.get('https://webcamtests.com/check')
  .then(function() {
    setTimeout(function() {
      driver.findElement(webdriver.By.id("webcam-launcher")).click()
        .then(function() {
          setTimeout(function() {
            // Microphone Test
            driver.get('https://www.vidyard.com/mic-test/')
              .then(function() {
                driver.findElement(webdriver.By.xpath("//a[@id='start-test']")).click()
                  .then(function() {
                    setTimeout(function() {
                        driver.quit();
                    }, 2000);
                });
              });
          }, 2000);
        });
    }, 2000);
  });
Copy code
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using System.Threading;
using OpenQA.Selenium.Chrome;

namespace SampleCSharp
{
    public class AllowCameraMicPopupChrome
    {
        static void Main(string[] args)
        {
            IWebDriver driver;

            //Configure ChromeOptions to pass fake media stream
            ChromeOptions chromeOptions = new ChromeOptions();
            chromeOptions.AddArgument("--use-fake-device-for-media-stream");
            chromeOptions.AddArgument("--use-fake-ui-for-media-stream");

            capability.AddAdditionalCapability("browserName", "Chrome", true);
            capability.AddAdditionalCapability("version", "latest", true);
            capability.AddAdditionalCapability("platform", "WIN10", true);
            capability.AddAdditionalCapability("key", "key", true);
            capability.AddAdditionalCapability("secret", "secret", true);
            capability.AddAdditionalCapability("chromeOptions", chromeOptions, true);

            driver = new RemoteWebDriver(new Uri("http://hub.testingbot.com/wd/hub/"), capability);

            // Webcam Test           
            driver.Navigate().GoToUrl("https://webcamtests.com/check");
            Thread.Sleep(2000);
            driver.FindElement(By.Id("webcam-launcher")).Click();
            Thread.Sleep(5000);

            // 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.

Copy code
require 'rubygems'
require 'selenium-webdriver'

# 0 - Default, 1 - Allow, 2 - Block
caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"prefs" => { "profile.default_content_setting_values.notifications" => 1 } })
caps['browserName'] = 'Chrome'
caps['version'] = 'latest'
caps['platform'] = 'WIN10'
driver = Selenium::WebDriver.for(:remote,
  :url => "https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub",
  :desired_capabilities => caps)

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
Copy code
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
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 {
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("browserName", "Chrome");
    caps.setCapability("version", "latest");
    caps.setCapability("platform", "WIN10");
    caps.setCapability(ChromeOptions.CAPABILITY, options);

    ChromeOptions options = new ChromeOptions();
    Map<String, Object> prefs = new HashMap<String, Object>();
    Map<String, Object> profile = new HashMap<String, Object>();
    Map<String, Object> contentSettings = new HashMap<String, Object>();

    // 0 - Default, 1 - Allow, 2 - Block
    contentSettings.put("notifications", 1);
    profile.put("managed_default_content_settings", contentSettings);
    prefs.put("profile", profile);
    options.setExperimentalOption("prefs", prefs);

    caps.setCapability(ChromeOptions.CAPABILITY, options);

    WebDriver driver = new RemoteWebDriver(new URL(URL), caps);

    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();
  }
}
Copy code
<?php

    require_once('vendor/autoload.php');
    use Facebook\WebDriver\Remote\RemoteWebDriver;
    use Facebook\WebDriver\WebDriverBy;

    $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_W3C,
        // There is a bug in php-webdriver, so ->toArray() is needed!
        $options->toArray()
    );
    $web_driver = RemoteWebDriver::create(
    "https://api_key:api_secret@hub.testingbot.com/wd/hub",
      $caps, 120000
    );
    
    $web_driver->get("https://web-push-book.gauntface.com/demos/notification-examples/");
    $element = $web_driver->findElement(WebDriverBy::xpath("//body/main[1]/p[3]/input[1]"));
    if ($element) {
      $element->click();
    }

    $web_driver->quit();
?>
Copy code
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
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})
desired_cap = chrome_options.to_capabilities()
desired_cap.update({
  'version': 'latest',
  'platform': 'WIN10',
  'browserName': 'chrome'
})
driver = webdriver.Remote(command_executor='https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub', desired_capabilities=desired_cap)
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()
Copy code
const webdriver = require('selenium-webdriver');
const chrome = require("selenium-webdriver/chrome");

const capabilities = {
  'browserName' : 'Chrome',
  'version' : 'latest',
  'platform' : 'WIN10',
  'goog:chromeOptions': {
    prefs: {
      // 0 - Default, 1 - Allow, 2 - Block
      'profile.managed_default_content_settings.notifications': 1
    }
  }
}

const driver = new webdriver.Builder()
  .usingServer('https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub')
  .withCapabilities(capabilities)
  .build();

driver.get('https://web-push-book.gauntface.com/demos/notification-examples/')
  .then(function() {
    driver.findElement(webdriver.By.xpath("//body/main[1]/p[3]/input[1]")).click()
      .then(function() {
        driver.quit();
      });
  });
Copy code
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using System.Threading;
using System.Collections.Generic;
using OpenQA.Selenium.Chrome;

namespace SampleCSharp
{
    public class Program
    {
        static void Main(string[] args)
        {
            RemoteWebDriver driver;
            Dictionary<string, object> profile = new Dictionary<string, object>();
            // 0 - Default, 1 - Allow, 2 - Block
            profile.Add("profile.default_content_setting_values.notifications", 1);
            Dictionary<string, object> chromeOptions = new Dictionary<string, object>();
            chromeOptions.Add("prefs", profile);

            // SET CAPABILITY
            ChromeOptions capability = new ChromeOptions();
            capability.AddAdditionalCapability("browserName", "Chrome", true);
            capability.AddAdditionalCapability("version", "latest", true);
            capability.AddAdditionalCapability("platform", "WIN10", true);
            capability.AddAdditionalCapability("key", "key", true);
            capability.AddAdditionalCapability("secret", "secret", true);
            capability.AddAdditionalCapability("chromeOptions", chromeOptions, true);

            driver = new RemoteWebDriver(new Uri("http://hub.testingbot.com/wd/hub/"), capability);
            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

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

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

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

Copy code
require 'rubygems'
require 'selenium-webdriver'

caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"prefs" => { "profile.content_settings.exceptions.clipboard" => '*': {'setting': 1} } })
caps['browserName'] = 'Chrome'
caps['version'] = 'latest'
caps['platform'] = 'WIN10'
driver = Selenium::WebDriver.for(:remote,
  :url => "https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub",
  :desired_capabilities => caps)

driver.navigate.to "https://permission.site/#read-text"
driver.find_element(:id, "read-text").click;
sleep(2)
driver.quit
Copy code
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
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) throws JsonProcessingException {
    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);
    ObjectMapper objectMapper = new ObjectMapper();
    String json = objectMapper.writeValueAsString(cbPreference);
    logger.info("clipboardSettingJson: " + json);
    return cbPreference;
  }

  public static void main(String[] args) throws Exception {
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("browserName", "Chrome");
    caps.setCapability("version", "latest");
    caps.setCapability("platform", "WIN10");
    caps.setCapability(ChromeOptions.CAPABILITY, options);

    ChromeOptions options = new ChromeOptions();
    Map<String, Object> prefs = new HashMap<String, Object>();
    Map<String, Object> profile = new HashMap<String, Object>();
    Map<String, Object> contentSettings = new HashMap<String, Object>();

    prefs.put("profile.content_settings.exceptions.clipboard", getClipBoardSettingsMap(1));
    options.setExperimentalOption("prefs", prefs);

    caps.setCapability(ChromeOptions.CAPABILITY, options);

    WebDriver driver = new RemoteWebDriver(new URL(URL), caps);

    driver.get("https://permission.site/#read-text");
    driver.findElement(By.id("read-text")).click();
    Thread.sleep(2000);
    driver.quit();
  }
}
Copy code
// no example yet
Copy code
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
import time

chrome_options = Options()
chrome_options.add_preference('profile.content_settings.exceptions.clipboard', {
    '*': {'setting': 1}
  })
desired_cap = chrome_options.to_capabilities()
desired_cap.update({
  'version': 'latest',
  'platform': 'WIN10',
  'browserName': 'chrome'
})
driver = webdriver.Remote(command_executor='https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub', desired_capabilities=desired_cap)
driver.get("https://permission.site/#read-text")
driver.find_element_by_id("read-text").click()
time.sleep(2)
driver.quit()
Copy code
const webdriver = require('selenium-webdriver');
const { Options } = require('selenium-webdriver/chrome');

const options = new Options()
options.setUserPreferences({
    profile: {
        content_settings: {
            exceptions: {
                clipboard: {
                    ['https://permission.site,*']:
                        {
                            "expiration": "0",
                            "last_modified": Date.now(),
                            "model": 0,
                            "setting": 1
                        },
                }
            }
        }
    }
})

const capabilities = {
  'browserName' : 'Chrome',
  'version' : 'latest',
  'platform' : 'WIN10'
}
capabilities.merge(options.toCapabilities());

const driver = new webdriver.Builder()
  .usingServer('https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub')
  .withCapabilities(capabilities)
  .build();

driver.get('https://permission.site/#read-text')
  .then(function() {
    driver.findElement(webdriver.By.id("read-text")).click()
      .then(function() {
        driver.quit();
      });
  });
Copy code
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using System.Threading;
using System.Collections.Generic;
using OpenQA.Selenium.Chrome;

namespace SampleCSharp
{
    public class Program
    {
        static void Main(string[] args)
        {
            RemoteWebDriver driver;
            ChromeOptions capability = new ChromeOptions();
            var clipboardException = new Dictionary<string, object> {
              {"[*.]myurl.com,*", 
                new Dictionary<string, object> {
                  {"last_modified", DateTimeOffset.Now.ToUnixTimeMilliseconds()}, 
                  {"setting", 1}
                }
              }
            };
            profile.Add("profile.content_settings.exceptions.clipboard", clipboardException);
            chromeOptions.Add("prefs", profile);
            capability.AddAdditionalCapability("browserName", "Chrome", true);
            capability.AddAdditionalCapability("version", "latest", true);
            capability.AddAdditionalCapability("platform", "WIN10", true);
            capability.AddAdditionalCapability("key", "key", true);
            capability.AddAdditionalCapability("secret", "secret", true);
            capability.AddAdditionalCapability("chromeOptions", chromeOptions, true);

            driver = new RemoteWebDriver(new Uri("https://hub.testingbot.com/wd/hub/"), capability);
            driver.Navigate().GoToUrl("https://permission.site/#read-text");
            driver.FindElement(By.Id("read-text")).Click();
            Thread.Sleep(2000);
            driver.Quit();
        }
    }
}