Skip to content

Instantly share code, notes, and snippets.

@hjwp
hjwp / geckodriver.log
Last active February 1, 2017 10:27
selenium geckodriver submit form back-n bug
1485944341219 geckodriver INFO Listening on 127.0.0.1:41675
1485944341325 mozprofile::profile INFO Using profile path /tmp/rust_mozprofile.t3ZWzjAMYYxm
1485944341326 geckodriver::marionette INFO Starting browser /usr/bin/firefox
1485944341329 geckodriver::marionette INFO Connecting to Marionette on localhost:37053
1485944342011 Marionette INFO Listening on port 37053
JavaScript error: chrome://marionette/content/listener.js, line 1028: NS_ERROR_UNKNOWN_PROTOCOL:
[Child 14847] ###!!! ABORT: Aborting on channel error.: file /build/firefox-K2Dm8Y/firefox-51.0.1+build2/ipc/glue/MessageChannel.cpp, line 2056
[Child 14847] ###!!! ABORT: Aborting on channel error.: file /build/firefox-K2Dm8Y/firefox-51.0.1+build2/ipc/glue/MessageChannel.cpp, line 2056
1485944344034 geckodriver INFO Listening on 127.0.0.1:34003
1485944345118 mozprofile::profile INFO Using profile path /tmp/rust_mozprofile.O1yJi6VSZJ7i
#!/usr/bin/env python
from contextlib import closing
from datetime import datetime
import json
import MySQLdb
DB_NAME = 'x'
DB_USER = 'y'
DB_PASS = 'z'
class PayPalPages(object):
def __init__(self, test, browser):
self.test = test
self.browser = browser
@contextmanager
def reload_if_paypal_cannot_get(self):
yield
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hjwp
hjwp / asyncio_prints.py
Created December 7, 2015 05:32
an illustration of the difference between "yield from" and "create_task" in asyncio
import asyncio
import random
@asyncio.coroutine
def print_whenever(identifier):
"""a little function that prints at random intervals"""
while True:
yield from asyncio.sleep(random.choice([0.5, 1, 1.3]))
print('hi from', identifier)
@hjwp
hjwp / conftest.py
Created June 30, 2015 15:41
pytest: print fixture output after test runs
import pytest
@pytest.mark.hookwrapper
def pytest_pyfunc_call(pyfuncitem):
yield
print('pyfunc call after')
if 'watch_logs' in pyfuncitem.funcargs:
print(pyfuncitem.funcargs['watch_logs']())
@hjwp
hjwp / _output.txt
Last active August 29, 2015 14:23
pytest print in finalizer 2
➜ t2 py.test tests.py
============================= test session starts =============================
platform linux -- Python 3.4.3 -- py-1.4.30 -- pytest-2.7.2
rootdir: /tmp/t2, inifile:
collected 2 items
tests.py .F
================================== FAILURES ===================================
______________________________ test_should_fail _______________________________
@hjwp
hjwp / conftest.py
Last active August 29, 2015 14:23
pytest print in finalizer attempts
import time
import pytest
def pytest_runtest_call(item):
if hasattr(item, "_request"):
if hasattr(item._request, "_addoutput_on_failure"):
item._request._addoutput_on_failure()
@pytest.fixture
@hjwp
hjwp / conftest.py
Last active August 29, 2015 14:23
pytest finalizer that prints?
import pytest
@pytest.yield_fixture
def print_on_fail():
yield
print('test failed')
@hjwp
hjwp / test_chromedrive_autocapitalize_off.py
Created May 26, 2015 12:27
Minimal repro of chromedriver bug
import tempfile
from selenium import webdriver
htmlfile = tempfile.NamedTemporaryFile(suffix='.html', delete=False)
with htmlfile.file:
htmlfile.file.write('<!DOCTYPE html><html><input type="text" autocapitalize="off" /></html>')
def check_browser(browser):
browser.implicitly_wait(1)