Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import pytest
from selenium import webdriver
from pdb import set_trace
from poms_google import *
from html.parser import HTMLParser
class HP(HTMLParser):
def handle_starttag(self, tag, attrs):
#print("start tag: ", tag, attrs)
happy = {}
interesting = ['value', 'id', 'name', 'type']
pr = tag
go = False
for att in attrs:
if att[0] in interesting:
go = True
pr += " %s: %s" % (att[0], att[1])
if go:
driver = webdriver.Chrome()
hp = HP()
def dump():
# get elements with text
#intr = [ el for el in els if el.text != '' ]
#for e in intr:
for e in els:
iid = e.get_attribute('id')
pid = e.get_property('id')
name = e.get_property('name')
val = e.get_property('value')
ttype = e.get_property('type')
avoid = ['html', 'body']
print("%s %s %s %s %s %s" % (e.tag_name, iid, pid, name, ttype, e.text))
if e.tag_name not in avoid:
if e.text != '' and val != '':
print("%s %s %s %s %s" % (e.tag_name, iid, pid, name, e.text))
def parse_dump():
home = GoogleHome(driver)
els = driver.find_elements_by_xpath('//*')
#intr = dump()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment