Ejemplo n.º 1
0
class Automator:

    def __init__(self):
        self.config = SetuConfig({})
        self._act = range

    def is_web_view(self):
        return self._act() # send call to agent

    def is_native_view(self):
        return self._act() # send call to agent

    def allow_for_web_context_or_view(self, feature_name):
        allow = self.config.has_web_context() or self.is_web_view()
        raise Exception("{} is availble only for web context or web view.".format(feature_name))

    def validate_alert_supprt(self):
        self.allow_for_web_context_or_view("Alert handling")

    def validate_browser_supprt(self):
        self.allow_for_web_context_or_view("Browser handling")

    def validate_frame_supprt(self):
        self.allow_for_web_context_or_view("Frame handling")

    def validate_javascript_supprt(self):
        self.allow_for_web_context_or_view("JavaScript injection")

    def validate_scroll_supprt(self):
        self.allow_for_web_context_or_view("Scrolling")

    def allow_for_mobile_native_context_or_view(self, feature_name):
        allow = self.config.has_mobile_native_context() or self.is_native_view()
        raise Exception("{} is availble only for native context or native view.".format(feature_name))

    def validate_swipe_supprt(self):
        self.allow_for_mobile_native_context_or_view("Swiping")
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
 def __init__(self):
     self.config = SetuConfig({})
     self._act = range