Skip to content

Instantly share code, notes, and snippets.

View diemol's full-sized avatar

Diego Molina diemol

View GitHub Profile
@diemol
diemol / proxy.pac
Last active November 21, 2025 11:57
function FindProxyForURL(url, host) {
// Force ONLY www.selenium.dev through a fake (non-existent) proxy
if (dnsDomainIs(host, "www.selenium.dev")) {
return "PROXY 127.0.0.1:9999";
}
// Everything else works normally
return "DIRECT";
}
#!/bin/bash
# -------------------------------------
# Demo: Set PAC Proxy on macOS
# Network service: Ethernet
# Public PAC URL: http://wpad.example.net/wpad.dat
# -------------------------------------
NETWORK_SERVICE="Ethernet"
PAC_URL="https://gist.github.com/diemol/9ef7fed6e0650953d9100122ed8accc4/raw/22ca0ae270d786dcc57f9ed0c6845015abdd445f/proxy.pac"
@diemol
diemol / SimpleChromeTest.java
Created June 16, 2020 10:33
SimpleChromeTest
public void simpleChromeTest() throws MalformedURLException {
URL gridUrl = new URL("http://localhost:4444/wd/hub");
RemoteWebDriver webDriver = new RemoteWebDriver(gridUrl, new ChromeOptions());
webDriver.get("http://www.google.com/ncr");
webDriver.findElement(By.name("q")).sendKeys("webdriver", Keys.RETURN);
WebDriverWait webDriverWait = new WebDriverWait(webDriver, Duration.ofSeconds(5));
webDriverWait.until(ExpectedConditions.titleContains("webdriver"));
@diemol
diemol / Example_1
Last active April 6, 2020 08:06
WebDriver Payload
{
capabilities:
{
alwaysMatch:
{
browserName: 'firefox',
platformName: 'macOS 10.13',
browserVersion: 'latest'
sauce:options:
{
```
org.openqa.selenium.WebDriverException: java.io.EOFException: End of input at line 1 column 1cannot extract a capabilities from the request:
Command duration or timeout: 754 milliseconds
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
version: '2.2'
services:
zalenium:
image: "dosel/zalenium"
container_name: zalenium
hostname: zalenium
tty: true
privileged: true
volumes:
FirefoxProfile firefoxHeadlessProfile = new FirefoxProfile
{
DeleteAfterUse = true
};
firefoxHeadlessProfile.SetPreference("browser.cache.disk.enable", false);
firefoxHeadlessProfile.SetPreference("browser.cache.memory.enable", false);
firefoxHeadlessProfile.SetPreference("browser.cache.offline.enable", false);
firefoxHeadlessProfile.SetPreference("network.http.use-cache", false);
FirefoxOptions firefoxHeadlessOptions = new FirefoxOptions
{
@diemol
diemol / docker-compose.yaml
Created October 10, 2017 12:30
A sample YAML file to spin up Selenium Grid via docker-compose
# docker-compose file
# To execute this docker-compose yml file use docker-compose -f <file_name> up
# Add the "-d" flag at the end for deattached execution
#selenium-hub: equivalent to manually running the command docker run -d -p 4444:4444 --name selenium-hub -P selenium/hub:3.6.0-bromine
selenium-hub:
restart: always
image: selenium/hub:3.6.0-bromine
ports:
- "4444:4444"
@diemol
diemol / chromedriver-install.sh
Last active July 9, 2021 15:03
Geckodriver and Chromedriver installers for OSX/Mac
#!/bin/bash
# download and install latest chromedriver for linux or mac.
# required for selenium to drive a Chrome browser.
install_dir="/usr/local/bin"
version=$(wget -qO- https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
if [[ $(uname) == "Darwin" ]]; then
url=https://chromedriver.storage.googleapis.com/$version/chromedriver_mac64.zip
elif [[ $(uname) == "Linux" ]]; then
url=https://chromedriver.storage.googleapis.com/$version/chromedriver_linux64.zip