Ejemplo n.º 1
0
import time

from setu import GuiAutomator, SimpleGuiElementMetaData
from setu.core.config.ex import EX_CONFIG
from setu.core.config.config_utils import SetuConfig

from wp_login_logout import login, logout

automator = GuiAutomator("http://localhost:9898", SetuConfig(EX_CONFIG))
login(automator)

automator.take_screenshot()

automator.create_element_with_locator("link_text", "Posts").click()
automator.create_element_with_locator("link_text", "Categories").click()
checkboxes = automator.create_multielement_with_locator(
    "name", "delete_tags[]")
checkboxes.get_instance_at_index(0).check()
checkboxes.get_instance_at_index(0).uncheck()
checkboxes.get_instance_at_index(0).check()
# Should not change the state
checkboxes.get_instance_at_index(0).check()
checkboxes.get_instance_at_index(1).check()

logout(automator)
import time

from setu import GuiAutomator, SimpleGuiElementMetaData
from setu.core.config.ex import EX_CONFIG
from setu.core.config.config_utils import SetuConfig

from wp_login_logout import login, logout

automator = GuiAutomator("http://localhost:9898", SetuConfig(EX_CONFIG))
login(automator)

win_handler = automator.window_handler
print(win_handler.get_current_window_handle())
print(win_handler.get_current_window_size())
print(win_handler.get_all_window_handles())
win_handler.set_window_size(200, 400)
time.sleep(5)
win_handler.maximize_window()
time.sleep(5)
print(win_handler.get_window_title())
automator.execute_javascript("window.open('google.com')")
print(win_handler.get_all_window_handles())
print(win_handler.get_window_title())
time.sleep(5)
win_handler.switch_to_new_window()
print(win_handler.get_window_title())
win_handler.close_current_window()
time.sleep(5)
automator.execute_javascript("window.open('google.com')")
print(win_handler.get_all_window_handles())
time.sleep(5)
Ejemplo n.º 3
0
import time

from setu import GuiAutomator, SimpleGuiElementMetaData
from setu.core.config.ex import EX_CONFIG
from setu.core.config.config_utils import SetuConfig
from wp_login_logout import login, logout

automator = GuiAutomator("http://localhost:9898", SetuConfig(EX_CONFIG))
login(automator)

alert_handler = automator.alert_handler
automator.execute_javascript("alert('dummy')")
alert_handler.create_alert().confirm()
automator.execute_javascript("alert('dummy')")
alert_handler.create_alert().dismiss()

automator.execute_javascript("alert('Sample')")
alert = alert_handler.create_alert()
assert alert.get_text() == "Sample"
alert.confirm()
time.sleep(3)

automator.execute_javascript("prompt('Are You Sure?')")
alert = alert_handler.create_alert()
alert.send_text("Yes")
alert.confirm()
time.sleep(3)

logout(automator)
Ejemplo n.º 4
0
import time

from setu import GuiAutomator
from setu.core.config.ex import EX_CONFIG
from setu.core.config.config_utils import SetuConfig

#####################
# Creating Gui Automator
#####################

automator = GuiAutomator("http://localhost:9898", SetuConfig(EX_CONFIG))


def login(automator):
    automator.launch()

    automator.browser_navigator.to("http://192.168.56.103/wp-admin")
    automator.create_element_with_locator("id", "user_login").set_text("user")
    automator.create_element_with_locator("id",
                                          "user_pass").set_text("bitnami")
    automator.create_element_with_locator("id", "wp-submit").click()
    automator.create_element_with_locator(
        "class_name", "welcome-view-site").wait_until_clickable()


def logout(automator):
    automator.browser_navigator.to(
        "http://192.168.56.103/wp-login.php?action=logout")
    automator.quit()
Ejemplo n.º 5
0
import time

from setu import GuiAutomator, SimpleGuiElementMetaData
from setu.core.config.ex import EX_CONFIG
from setu.core.config.config_utils import SetuConfig
from wp_login_logout import login, logout

automator = GuiAutomator("http://localhost:9898", SetuConfig(EX_CONFIG))
login(automator)

automator.create_element_with_locator("link_text","Settings").click()
data_format = automator.create_radiogroup_with_locator("name", "date_format")
time.sleep(2)
print(data_format.has_value_selected("Y-m-d"))
time.sleep(2)
print(data_format.has_index_selected(1))
time.sleep(2)
print(data_format.get_first_selected_option_value())
time.sleep(2)
data_format.select_by_value(r'\c\u\s\t\o\m')
time.sleep(2)
data_format.select_by_index(2)

logout(automator)
Ejemplo n.º 6
0
import time

from setu import GuiAutomator, SimpleGuiElementMetaData
from setu.core.config.ex import EX_CONFIG
from setu.core.config.config_utils import SetuConfig
from wp_login_logout import login, logout

automator = GuiAutomator("http://localhost:9898", SetuConfig(EX_CONFIG))
login(automator)

automator.create_element_with_locator("link_text", "Posts").click()
automator.create_element_with_locator("link_text", "Add New").click()

automator.create_element_with_locator("id", "title").set_text("Sample")

# jump to frame by name
frame = automator.create_frame_with_locator("id", "content_ifr")
frame.jump()
tiny_mce = automator.create_element_with_locator("id", "tinymce")
tiny_mce.set_text("This is a test - frame by name.")
frame.jump_to_root()
automator.create_element_with_locator("id", "publish").click()
time.sleep(5)
# jump to frame by index
frame = automator.create_frame_with_locator("index", "0")
frame.jump()
tiny_mce = automator.create_element_with_locator("id", "tinymce")
tiny_mce.set_text("This is a test - frame by index.")
frame.jump_to_root()
automator.create_element_with_locator("id", "publish").click()
time.sleep(5)
Ejemplo n.º 7
0
import time

from setu import GuiAutomator, SimpleGuiElementMetaData
from setu.core.config.ex import EX_CONFIG
from setu.core.config.config_utils import SetuConfig
from wp_login_logout import login, logout

automator = GuiAutomator("http://localhost:9898", SetuConfig(EX_CONFIG))
login(automator)

automator.create_element_with_locator("link_text", "Settings").click()
role_select = automator.create_dropdown_with_locator("id", "default_role")
print(role_select.has_visible_text_selected("Subscriber"))
print(role_select.has_value_selected("subscriber"))
print(role_select.has_index_selected(2))
print(role_select.get_first_selected_option_text())
role_select.select_by_value("editor")
role_select.select_by_visible_text("Subscriber")
role_select.select_by_index(4)

logout(automator)