Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Attempt to reinstall this existing certificate
2: Renew & replace the certificate (may be subject to CA rate limits)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1
Keeping the existing certificate
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/000-default-le-ssl.conf
Enhancement redirect was already set.
def wait_for_element_visible(self, element, timeout=10):
for x in range(4 * timeout):
try:
element = self.browser.find_element(by=by, value=identity)
if element.is_displayed():
return element
else:
element = None
time.sleep(0.25)
except Exception:
@dougdragon
dougdragon / wait_for_element_present.py
Created August 4, 2016 17:23
python function to wait for an element to be present on the DOM
def wait_for_element_present(self, selector,
by=By.CSS_SELECTOR, timeout=30):
"""
Searches for the specified element by the given selector. Returns the
element object if the element is present on the page. The element can be
invisible. Raises an exception if the element does not appear in the
specified timeout.
@Params
selector - the locator that is used, can be either a Locator instance or a
webdriver find value (required)
from ftplib import FTP as ftp
username = 'username'
passwd = 'password'
dir_loc = 'directory_of_ftp'
file_name = 'filename_to_upload'
def main():
session = ftp(dir_loc)
session.login(username, passwd)
def select_dropdown_option(self, identity, text, by=By.CSS_SELECTOR):
"""
Selects a dropdown option
:param identity: css selector(default) of select
If you want to use a different one (id, name, xpath-gross) pass the by
parameter
:param text: The text of the dropdown you want
:param by: the method of locating the identity (defaults to CSS)
"""
select = Select(self.browser.find_element(by=by, value=identity))

Keybase proof

I hereby claim:

  • I am dougdragon on github.
  • I am dougdragon (https://keybase.io/dougdragon) on keybase.
  • I have a public key whose fingerprint is FAD4 46B5 4795 BAD2 6548 A930 696E 6859 9B15 CB86

To claim this, I am signing this object:

@dougdragon
dougdragon / hover_and_click.py
Last active August 29, 2015 14:14
Python function to hover on an element and click on another using selenium
def hover_and_click(self, hover_selector, click_selector,
click_by=By.CSS_SELECTOR, timeout=5):
"""
Fires the hover event for a specified element by a given selector, then
clicks on another element specified. Useful for dropdown hover based menus.
@Params
hover_selector - the locator (css selector) that is used to hover
(required)
click_selector - the locator that is used to click (required)
click_by - the method to search for the locator (Default- By.CSS_SELECTOR)
@dougdragon
dougdragon / gist:a617b17156ad244e30b8
Created July 31, 2014 23:53
dropdown selection example
options = driver.find_elements_by_css_selector("div.chosen-search ul li")
for option in options:
if "California" in option.text:
option.click()
break
@dougdragon
dougdragon / wait_for_element_visible
Created April 23, 2014 19:21
wait_for_element_visible in Python using Selenium
def wait_for_element_visible(driver,
selector,
by=By.CSS_SELECTOR,
timeout=30):
"""
Searches for the specified element by the given selector. Returns the
element object if the element is present and visible on the page.
Raises an exception if the element does not appear in the
specified timeout.
@Params
<?php
function hide_email($email) {
$character_set = '+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
$key = str_shuffle($character_set); $cipher_text = ''; $id = 'e'.rand(1,999999999);
for ($i=0;$i<strlen($email);$i+=1) $cipher_text.= $key[strpos($character_set,$email[$i])];
$script = 'var a="'.$key.'";var b=a.split("").sort().join("");var c="'.$cipher_text.'";var d="";';
$script.= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));';
$script.= 'document.getElementById("'.$id.'").innerHTML="<a href=\\"mailto:"+d+"\\">"+d+"</a>"';
$script = "eval(\"".str_replace(array("\\",'"'),array("\\\\",'\"'), $script)."\")";
$script = '<script type="text/javascript">/*<![CDATA[*/'.$script.'/*]]>*/</script>';