go_to_wp_home(automator)


def cleanup():
    global automator
    global melement
    for i in range(melement.length):
        print(melement.at_index(i).source.content.root)
    automator.quit()
    melement = None
    automator = None


setup()
melement = automator.multi_element(
    With.javascript("return document.getElementById('wp-submit')"))
cleanup()

setup()
melement = automator.multi_element(
    With.javascript("return document.getElementsByClassName('input')"))
cleanup()

# setup()
# melement = automator.multi_element(With.javascript("return null"))
# cleanup()

# setup()
# melement = automator.multi_element(With.javascript("return [undefined]"))
# cleanup()
element = automator.element(With.attr_pvalue("[for][_login]"))
element.identify()
print(element.source.content.root)

# Based on element type
element = automator.element(With.type("password"))
element.identify()
print(element.source.content.root)

# Based on compound classes
element = automator.element(With.compound_class("button button-large"))
element.identify()
print(element.source.content.root)

# Based on class names
element = automator.element(With.class_names("button", "button-large"))
element.identify()
print(element.source.content.root)

# Based on Point (location in terms of X,Y co-ordinates)
element = automator.element(With.point(Screen.xy(1043, 458)))
element.identify()
print(element.source.content.root)

# With Javascript
element = automator.element(With.javascript("return document.getElementById('wp-submit')"))
element.identify()
print(element.source.content.root)
# To understand this further look at the javascript situations code

automator.quit()