Example #1
0
def logout(automator):
    url = automator.config.get_user_option_value("wp.logout.url").as_str()
    automator.browser.go_to_url(url)

    automator.element(With.link_ptext("log out")).click()
    message = automator.element(With.ptext("logged out")).wait_until_visible()

    automator.quit()
from commons import *
from arjuna.tpi.guiauto.helpers import With, Screen

init_arjuna()

automator = launch_automator()
go_to_wp_home(automator)

user, pwd = automator.config.get_user_option_value(
    "wp.users.admin").split_as_str_list()

# Login
automator.element(With.id("user_login")).set_text(user)
automator.element(With.id("user_pass")).set_text(pwd)
automator.element(With.id("wp-submit")).click()

automator.element(With.class_name("welcome-view-site")).wait_until_visible()

# Logout
url = automator.config.get_user_option_value("wp.logout.url").as_str()
automator.browser.go_to_url(url)

automator.element(With.link_ptext("log out")).click()
message = automator.element(With.ptext("logged out")).wait_until_visible()

automator.quit()
user_field = automator.element(With.id("user_login"))
user_field.identify()
user_field.wait_until_clickable()
user_field.set_text(user)

pwd_field = automator.element(With.id("user_pass"))
pwd_field.identify()
pwd_field.wait_until_clickable()
pwd_field.set_text(pwd)

submit = automator.element(With.id("wp-submit"))
submit.identify()
submit.wait_until_clickable()
submit.click()

automator.element(With.class_name("welcome-view-site")).wait_until_visible()

# Logout
url = automator.config.get_user_option_value("wp.logout.url").as_str()
automator.browser.go_to_url(url)

confirmation = automator.element(With.link_ptext("log out"))
confirmation.identify()
confirmation.wait_until_clickable()
confirmation.click()

message = automator.element(With.ptext("logged out"))
message.identify()
message.wait_until_visible()

automator.quit()
from commons import *
from arjuna.tpi.guiauto.helpers import With, Screen

init_arjuna()

automator = launch_automator()
go_to_wp_home(automator)

# Based on Text
element = automator.element(With.text("Lost your password?"))
element.identify()
print(element.source.content.root)

# Based on partial text
element = automator.element(With.ptext("Lost"))
element.identify()
print(element.source.content.root)

# Based on Title
element = automator.element(With.title("Password Lost and Found"))
element.identify()
print(element.source.content.root)

# Based on Value
element = automator.element(With.value("Log In"))
element.identify()
print(element.source.content.root)

# Based on any attribute e.g. for
element = automator.element(With.attr_value("[for][user_login]"))
element.identify()