Skip to content

Commit

Permalink
Merge pull request #37 from Integration-Automation/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
JE-Chen committed Jul 17, 2023
2 parents ed83ad4 + a938749 commit 909120c
Show file tree
Hide file tree
Showing 21 changed files with 302 additions and 35 deletions.
3 changes: 3 additions & 0 deletions automation_editor/automation_editor_ui/editor_main/main_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
menu.api_testka_menu.build_api_testka_menu import set_apitestka_menu
from automation_editor.automation_editor_ui. \
menu.auto_control_menu.build_autocontrol_menu import set_autocontrol_menu
from automation_editor.automation_editor_ui.menu.automation_file_menu.build_automation_file_menu import \
set_automation_file_menu
from automation_editor.automation_editor_ui.menu.install_menu.build_install_menu import set_install_menu
from automation_editor.automation_editor_ui.menu. \
load_density_menu.build_load_density_menu import set_load_density_menu
Expand All @@ -29,6 +31,7 @@ def __init__(self, debug_mode: bool = False, **kwargs):
set_apitestka_menu(self)
set_load_density_menu(self)
set_web_runner_menu(self)
set_automation_file_menu(self)
set_install_menu(self)
syntax_extend_package(self)
complete_extend_package(self)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import sys
import webbrowser

import je_auto_control
from PySide6.QtGui import QAction
from PySide6.QtWidgets import QMainWindow
from PySide6.QtWidgets import QMainWindow, QPlainTextEdit

from automation_editor.utils.test_executor.auto_control.auto_control_process import \
call_auto_control_test, call_auto_control_test_with_send, call_auto_control_test_multi_file, \
Expand Down Expand Up @@ -87,6 +88,23 @@ def set_autocontrol_menu(ui_we_want_to_set: QMainWindow):
ui_we_want_to_set.autocontrol_project_menu.addAction(
ui_we_want_to_set.create_autocontrol_project_action
)
# Record
ui_we_want_to_set.autocontrol_record_menu = ui_we_want_to_set.autocontrol_menu.addMenu("Record")
ui_we_want_to_set.record_action = QAction("Start Record")
ui_we_want_to_set.record_action.triggered.connect(
je_auto_control.record
)
ui_we_want_to_set.autocontrol_record_menu.addAction(
ui_we_want_to_set.record_action
)
# Stop Record
ui_we_want_to_set.stop_record_action = QAction("Stop Record")
ui_we_want_to_set.stop_record_action.triggered.connect(
lambda: stop_record(ui_we_want_to_set.code_edit)
)
ui_we_want_to_set.autocontrol_record_menu.addAction(
ui_we_want_to_set.stop_record_action
)


def open_web_browser(url: str) -> None:
Expand All @@ -101,3 +119,7 @@ def create_project() -> None:
package.create_project_dir()
except ImportError as error:
print(repr(error), file=sys.stderr)


def stop_record(set_stop_record_text_container: QPlainTextEdit):
set_stop_record_text_container.appendPlainText(str(je_auto_control.stop_record()))
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import sys
import webbrowser

from PySide6.QtGui import QAction
from PySide6.QtWidgets import QMainWindow

from automation_editor.utils.test_executor.file_automation.file_automation_process import call_file_automation_test, \
call_file_automation_test_with_send, call_file_automation_test_multi_file, \
call_file_automation_test_multi_file_and_send


def set_automation_file_menu(ui_we_want_to_set: QMainWindow):
"""
Build menu include WebRunner feature.
:param ui_we_want_to_set: main window to add menu.
:return: None
"""
ui_we_want_to_set.automation_file_menu = ui_we_want_to_set.menu.addMenu("FileAutomation")
ui_we_want_to_set.automation_run_file_menu = ui_we_want_to_set.automation_file_menu.addMenu("Run")
# Run FileAutomation Script
ui_we_want_to_set.run_file_automation_action = QAction("Run FileAutomation Script")
ui_we_want_to_set.run_file_automation_action.triggered.connect(
lambda: call_file_automation_test(
ui_we_want_to_set,
ui_we_want_to_set.code_edit.toPlainText()
)
)
ui_we_want_to_set.automation_run_file_menu.addAction(ui_we_want_to_set.run_file_automation_action)
# Run FileAutomation Script With Send
ui_we_want_to_set.run_file_automation_action_with_send = QAction("Run FileAutomation With Send")
ui_we_want_to_set.run_file_automation_action_with_send.triggered.connect(
lambda: call_file_automation_test_with_send(
ui_we_want_to_set,
ui_we_want_to_set.code_edit.toPlainText()
)
)
ui_we_want_to_set.automation_run_file_menu.addAction(
ui_we_want_to_set.run_file_automation_action_with_send
)
# Run Multi FileAutomation Script
ui_we_want_to_set.run_multi_file_automation_action = QAction("Run Multi FileAutomation Script")
ui_we_want_to_set.run_multi_file_automation_action.triggered.connect(
lambda: call_file_automation_test_multi_file(
ui_we_want_to_set,
)
)
ui_we_want_to_set.automation_run_file_menu.addAction(
ui_we_want_to_set.run_multi_file_automation_action
)
# Run Multi FileAutomation Script With Send
ui_we_want_to_set.run_multi_file_automation_action_with_send = QAction("Run Multi FileAutomation Script With Send")
ui_we_want_to_set.run_multi_file_automation_action_with_send.triggered.connect(
lambda: call_file_automation_test_multi_file_and_send(
ui_we_want_to_set,
)
)
ui_we_want_to_set.automation_run_file_menu.addAction(
ui_we_want_to_set.run_multi_file_automation_action_with_send
)
ui_we_want_to_set.file_automation_help_menu = ui_we_want_to_set.automation_file_menu.addMenu("HELP")
# # Open Doc
# ui_we_want_to_set.open_file_automation_doc_action = QAction("Open FileAutomation Doc")
# ui_we_want_to_set.open_file_automation_doc_action.triggered.connect(
# lambda: open_web_browser(
# "https://webrunner.readthedocs.io/en/latest/"
# )
# )
# ui_we_want_to_set.file_automation_help_menu.addAction(
# ui_we_want_to_set.open_file_automation_doc_action
# )
# Open Github
ui_we_want_to_set.open_file_automation_github_action = QAction("Open FileAutomation GitHub")
ui_we_want_to_set.open_file_automation_github_action.triggered.connect(
lambda: open_web_browser(
"https://github.com/Integration-Automation/FileAutomation"
)
)
ui_we_want_to_set.file_automation_help_menu.addAction(
ui_we_want_to_set.open_file_automation_github_action
)
ui_we_want_to_set.file_automation_project_menu = ui_we_want_to_set.automation_file_menu.addMenu("Project")
# Create Project
ui_we_want_to_set.create_web_runner_project_action = QAction("Create FileAutomation Project")
ui_we_want_to_set.create_web_runner_project_action.triggered.connect(
create_project
)
ui_we_want_to_set.file_automation_project_menu.addAction(
ui_we_want_to_set.create_web_runner_project_action
)


def open_web_browser(url: str) -> None:
webbrowser.open(url=url)


def create_project() -> None:
try:
import file_automation
package = file_automation
if package is not None:
package.create_project_dir()
except ImportError as error:
print(repr(error), file=sys.stderr)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def set_web_runner_menu(ui_we_want_to_set: QMainWindow):
"""
ui_we_want_to_set.web_runner_menu = ui_we_want_to_set.menu.addMenu("WebRunner")
ui_we_want_to_set.web_runner_run_menu = ui_we_want_to_set.web_runner_menu.addMenu("Run")
# Run WebRunner Script
# Run WEBRunner Script
ui_we_want_to_set.run_web_runner_action = QAction("Run WebRunner Script")
ui_we_want_to_set.run_web_runner_action.triggered.connect(
lambda: call_web_runner_test(
Expand All @@ -25,7 +25,7 @@ def set_web_runner_menu(ui_we_want_to_set: QMainWindow):
)
)
ui_we_want_to_set.web_runner_run_menu.addAction(ui_we_want_to_set.run_web_runner_action)
# Run AutoControl Script With Send
# Run WEBRunner Script With Send
ui_we_want_to_set.run_web_runner_action_with_send = QAction("Run WebRunner With Send")
ui_we_want_to_set.run_web_runner_action_with_send.triggered.connect(
lambda: call_web_runner_test_with_send(
Expand All @@ -36,7 +36,7 @@ def set_web_runner_menu(ui_we_want_to_set: QMainWindow):
ui_we_want_to_set.web_runner_run_menu.addAction(
ui_we_want_to_set.run_web_runner_action_with_send
)
# Run Multi AutoControl Script
# Run Multi WEBRunner Script
ui_we_want_to_set.run_multi_web_runner_action = QAction("Run Multi WebRunner Script")
ui_we_want_to_set.run_multi_web_runner_action.triggered.connect(
lambda: call_web_runner_test_multi_file(
Expand All @@ -46,7 +46,7 @@ def set_web_runner_menu(ui_we_want_to_set: QMainWindow):
ui_we_want_to_set.web_runner_run_menu.addAction(
ui_we_want_to_set.run_multi_web_runner_action
)
# Run Multi AutoControl Script With Send
# Run Multi WEBRunner Script With Send
ui_we_want_to_set.run_multi_web_runner_action_with_send = QAction("Run Multi WebRunner Script With Send")
ui_we_want_to_set.run_multi_web_runner_action_with_send.triggered.connect(
lambda: call_web_runner_test_multi_file_and_send(
Expand Down
27 changes: 18 additions & 9 deletions automation_editor/automation_editor_ui/syntax/syntax_keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"generate_json_report", "generate_xml",
"generate_xml_report", "execute_action", "execute_files", "add_package_to_executor",
"flask_mock_server_add_router",
"start_flask_mock_server"
]
"start_flask_mock_server"]

auto_control_keys: list = [
"mouse_left", "mouse_right", "mouse_middle", "click_mouse", "get_mouse_table", "get_mouse_position", "press_mouse",
"release_mouse", "mouse_scroll", "set_mouse_position", "get_special_table", "get_keyboard_keys_table",
Expand All @@ -13,8 +13,8 @@
"locate_image_center", "locate_and_click", "screen_size", "screenshot", "set_record_enable", "generate_html",
"generate_json", "generate_xml", "generate_html_report", "generate_json_report", "generate_xml_report", "record",
"stop_record", "execute_action", "execute_files", "add_package_to_executor", "add_package_to_callback_executor",
"create_project"
]
"create_project"]

web_runner_keys: list = [
"get_webdriver_manager", "change_index_of_webdriver", "quit", "SaveTestObject", "CleanTestObject", "set_driver",
"set_webdriver_options_capability", "find_element", "find_elements", "implicitly_wait", "explict_wait", "to_url",
Expand All @@ -32,17 +32,26 @@
"element_value_of_css_property", "element_screenshot", "element_change_web_element",
"element_check_current_web_element", "element_get_select", "set_record_enable", "generate_html",
"generate_html_report", "generate_json", "generate_json_report", "generate_xml", "generate_xml_report",
"execute_action", "execute_files", "add_package_to_executor", "add_package_to_callback_executor"
]
"execute_action", "execute_files", "add_package_to_executor", "add_package_to_callback_executor"]

load_density_keys: list = [
"start_test", "generate_html", "generate_html_report", "generate_json", "generate_json_report", "generate_xml",
"generate_xml_report", "execute_action", "execute_files", "add_package_to_executor"
]
"generate_xml_report", "execute_action", "execute_files", "add_package_to_executor"]

automation_file_keys: list = [
"create_file", "copy_file", "rename_file", "remove_file", "copy_all_file_to_dir",
"copy_specify_extension_file", "copy_dir", "create_dir", "remove_dir_tree", "zip_dir", "zip_file", "zip_info",
"zip_file_info", "set_zip_password", "unzip_file", "read_zip_file", "unzip_all", "drive_later_init",
"drive_search_all_file", "drive_search_field", "drive_search_file_mimetype", "drive_upload_dir_to_folder",
"drive_upload_to_folder", "drive_upload_dir_to_drive", "drive_upload_to_drive",
"drive_add_folder", "drive_share_file_to_anyone", "drive_share_file_to_domain",
"drive_share_file_to_user", "drive_delete_file", "drive_download_file", "drive_download_file_from_folder",
"execute_action", "execute_files", "add_package_to_executor"]

package_keyword_list = {
"je_auto_control": auto_control_keys,
"je_load_density": load_density_keys,
"je_api_testka": api_testka_keys,
"je_web_runner": web_runner_keys
"je_web_runner": web_runner_keys,
"automation_file": automation_file_keys
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def __init__(self):
"je_auto_control",
"je_load_density",
"je_api_testka",
"je_web_runner"
"je_web_runner",
"automation_file"
]


Expand Down
8 changes: 4 additions & 4 deletions automation_editor/utils/test_executor/check_mail_thunder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def check_mail_thunder_install():
if package_manager.installed_package_dict.get("je_mail_thunder", None) is None:
raise ITETestExecutorException(
not_install_exception + " je_mail_thunder"
)
try:
import je_mail_thunder
except ImportError:
raise ITETestExecutorException(not_install_exception + " je_mail_thunder")
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import json
import sys

from PySide6.QtWidgets import QMainWindow

from automation_editor.extend.mail_thunder_extend.mail_thunder_setting import send_after_test
from automation_editor.automation_editor_ui.show_code_window.code_window import CodeWindow
from automation_editor.utils.exception.exception_tags import wrong_test_data_format_exception_tag
from automation_editor.utils.exception.exceptions import ITETestExecutorException
from automation_editor.utils.file_process.get_dir_file_list import ask_and_get_dir_files_as_list
from automation_editor.utils.test_executor.check_mail_thunder import check_mail_thunder_install
from automation_editor.utils.test_executor.task_process_manager import TaskProcessManager


def call_file_automation_test(
main_window: QMainWindow,
test_format_code: str,
program_buffer: int = 1024000
):
try:
code_window = CodeWindow()
main_window.current_run_code_window.append(code_window)
TaskProcessManager(
main_window=code_window,
program_buffer_size=program_buffer
).start_test_process(
"automation_file",
exec_str=test_format_code,
)
except json.decoder.JSONDecodeError as error:
print(
repr(error) +
"\n"
+ wrong_test_data_format_exception_tag,
file=sys.stderr
)
except ITETestExecutorException as error:
print(repr(error), file=sys.stderr)


def call_file_automation_test_with_send(
main_window: QMainWindow,
test_format_code: str,
program_buffer: int = 1024000
):
try:
check_mail_thunder_install()
code_window = CodeWindow()
main_window.current_run_code_window.append(code_window)
TaskProcessManager(
main_window=code_window,
task_done_trigger_function=send_after_test,
program_buffer_size=program_buffer
).start_test_process(
"automation_file",
exec_str=test_format_code,
)
except json.decoder.JSONDecodeError as error:
print(
repr(error) +
"\n"
+ wrong_test_data_format_exception_tag,
file=sys.stderr
)
except ITETestExecutorException as error:
print(repr(error), file=sys.stderr)


def call_file_automation_test_multi_file(
main_window: QMainWindow,
program_buffer: int = 1024000
):
try:
need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window)
if need_to_execute_list is not None \
and isinstance(need_to_execute_list, list) and len(need_to_execute_list) > 0:
for execute_file in need_to_execute_list:
with open(execute_file, "r+") as test_script_json:
call_file_automation_test(
main_window,
test_script_json.read(),
program_buffer
)
except Exception as error:
print(repr(error), file=sys.stderr)


def call_file_automation_test_multi_file_and_send(
main_window: QMainWindow,
program_buffer: int = 1024000
):
try:
check_mail_thunder_install()
need_to_execute_list: list = ask_and_get_dir_files_as_list(main_window)
if need_to_execute_list is not None \
and isinstance(need_to_execute_list, list) and len(need_to_execute_list) > 0:
for execute_file in need_to_execute_list:
with open(execute_file, "r+") as test_script_json:
call_file_automation_test_with_send(
main_window,
test_script_json.read(),
program_buffer
)
except Exception as error:
print(repr(error), file=sys.stderr)
Loading

0 comments on commit 909120c

Please sign in to comment.