Example #1
0
'''
The following code is for user name field.
Html of user name: <input type="text" name="log" id="user_login" class="input" value="" size="20">

Params: 
APP URL: E.g. http://192.168.56.103
Page: E.g. wp-login
Resulting in http://192.168.56.103/wp-login.php
'''

identifier = r"//*[@action='$app_url$/$page$.php']"

app_url = automator.config.get_user_option_value("wp.app.url").as_str()
page = "wp-login"

element = automator.element(With.xpath(identifier).format(app_url=app_url, page=page))
element.identify()
print(element.source.content.root)


# Named params need not be passed in order, providing you flexibility, readability and preventing positional errors.
element = automator.element(With.xpath(identifier).format(page=page, app_url=app_url))
element.identify()
print(element.source.content.root)

# Names for parameters are case-insensitive
element = automator.element(With.xpath(identifier).format(PaGe=page, aPP_Url=app_url))
element.identify()
print(element.source.content.root)

logout(automator)
Example #2
0
automator = launch_automator()
login(automator)

automator.element(With.link_text("Posts")).click()
automator.element(With.link_text("Add New")).click()

tinymce = With.id("tinymce")
publish = With.id("publish")

# Frame by identifier and jump to root
automator.frame(With.id("content_ifr")).focus()
automator.element(tinymce).set_text("This is a test - frame by name.")
automator.dom_root.focus()
automator.element(publish).click()

# Frame by index
automator.frame(With.index(0)).focus()
automator.element(tinymce).set_text("This is a test - frame by index.")
# Focusing on root from frame itself
automator.dom_root.focus()
automator.element(publish).click()

# jump to parent
frame = automator.frame(With.xpath("//iframe"))
print(frame)
frame.focus()
automator.element(tinymce).set_text("This is a test - jumping to parent after this.")
frame.parent.focus()
automator.element(publish).click()

logout(automator)
Example #3
0
from commons import *
from arjuna.tpi.guiauto.helpers import With

init_arjuna()

automator = launch_automator()
go_to_wp_home(automator)

# Based on Text
element = automator.element(With.xpath("//*[text() = 'Lost your password?']"))
element.identify()
print(element.source.content.root)

# Based on partial text
element = automator.element(With.xpath("//*[contains(text(), 'Lost')]"))
element.identify()
print(element.source.content.root)

# Based on Title
element = automator.element(
    With.xpath("//*[@title = 'Password Lost and Found']"))
element.identify()
print(element.source.content.root)

# Based on Value
element = automator.element(With.xpath("//*[@value = 'Log In']"))
element.identify()
print(element.source.content.root)

# Based on any attribute e.g. for
element = automator.element(With.xpath("//*[@for = 'user_login']"))