Skip to content

Instantly share code, notes, and snippets.

View python012's full-sized avatar

Reed Xia python012

View GitHub Profile
@python012
python012 / WaitForMultipleElementsAsync.java
Created June 26, 2023 08:04
使用Java 8中提供的CompletableFuture来实现异步等待多个Web元素的功能。下面是一个可能的解决方案
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
python3 -m venv ./venv
source ./venv/bin/activate
pip3 install -r requirements.txt
pytest -vs --color=yes --disable-warnings --junitxml=result.xml --suppress-tests-failed-exit-code
@python012
python012 / pretty_print_xml.py
Last active August 19, 2019 02:47
pretty print xml node, work well with Chinese xml doc
from lxml import etree
import xml.dom.minidom as mmd
xml_root = etree.parse(xml_fiel_path, etree.XMLParser())
def print_xml(xml_root):
s = etree.tostring(xml).decode('utf-8')
urgly_xml = ''.join(s.split())
good_xml = mmd.parseString(urgly_xml)
print(good_xml.toprettyxml(indent=' ',))
@python012
python012 / vpn_monitor.py
Created November 19, 2018 11:36
add logging function
#coding: utf-8
#author: Reed Xia([email protected])
import smtplib
import config
import requests
import time
import base64
import sys
@python012
python012 / vpn_monitor_v3.py
Created November 16, 2018 11:25
new version, work with python 3.6
#coding: utf-8
import smtplib
import config
import urllib.request as urllib2
import time
import base64
last_email_sent_time = None
error_info = None
@python012
python012 / vpn_monitor.py
Last active November 9, 2018 07:55
new version of vpn monitor.py
#coding: utf-8
import smtplib
import config
import urllib.request as urllib2
import time
import base64
last_email_sent_time = None
error_info = None
@python012
python012 / settings.json
Created September 18, 2018 06:10
Custom VS code settings
{
"explorer.confirmDelete": false,
"workbench.iconTheme": "vscode-great-icons",
"editor.minimap.enabled": false,
"terminal.integrated.rendererType": "dom",
"editor.renderWhitespace": "none",
"files.autoSave": "afterDelay",
"editor.wrappingIndent": "none",
"window.zoomLevel": 0,
"vsicons.dontShowNewVersionMessage": true,
@python012
python012 / settings.json
Created September 14, 2018 08:37
VS Code settings as json file
{
"explorer.confirmDelete": false,
"workbench.iconTheme": "vscode-great-icons",
"editor.minimap.enabled": true,
"terminal.integrated.rendererType": "dom",
"editor.renderWhitespace": "none",
"files.autoSave": "afterDelay",
"editor.wrappingIndent": "none",
"window.zoomLevel": 0,
"vsicons.dontShowNewVersionMessage": true,
@python012
python012 / function.py
Created June 26, 2018 08:40
python lib inspect, could help check the target function's caller
import copy
import os
from importlib import import_module
from importlib.util import find_spec as importlib_find
import inspect
def import_string(dotted_path):
"""
Import a dotted module path and return the attribute/class designated by the
@python012
python012 / ScreenshotRule.java
Last active May 15, 2018 01:35
A JUnit TestWatcher to take screenshot when test fails.
package com.ibm.robot.web.testrules;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.openqa.selenium.OutputType;