Harmageddon Posted December 19, 2020 Posted December 19, 2020 Hi, I'm trying to get better at automating IE and I've came up with the issue of gathering the error messages. When the script is executed, I receive error "Failed to Submit: No Working Days Selected" which I want to get, however, I'm not able to catch it with my script. I've tried to check _IEDocReadHTML, _IEBodyReadText but both of these came up empty of this message. I understand that it's being generated by JS and it does fade away in few seconds. Inspection when message is present on screen: <div class="message warning fadable" style="opacity: 0.557469;">< Failed to Submit: No working Days Selected <a class="messageCloseButton" href="#">Close</a> </div> JS part: <script type="text/javascript"> //<![CDATA[ $("div.fadable").delay(2000) .fadeOut("slow", function () { $("div.fadable").remove(); }); //<![CDATA[ </script> Script to get to the error message: expandcollapse popup#include <IE.au3> Global $g_obj_IE Global Const $g_c_str_WebSiteURL = "https://opensource-demo.orangehrmlive.com/" Global $g_str_DefaultUserName = "Admin" Global $g_str_DefaultPassowrd = "admin123" Global $g_str_EmployeeName = "Jasmine Morgan" Global $g_str_LeaveType = "US - Vacation" $g_obj_IE = _IECreate($g_c_str_WebSiteURL) Global $g_str_FromDate = "2020-12-19" Global $g_str_ToDate = "2020-12-20" _EnterLoginDetails() _NavigateToAssignLeaveAndFillData() Func _EnterLoginDetails() Local $oUserNameWindow = _IEGetObjById($g_obj_IE, "txtUsername") Local $oPasswordWindows = _IEGetObjById($g_obj_IE, "txtPassword") Local $oLoginButton = _IEGetObjById($g_obj_IE, "btnLogin") _IEAction($oUserNameWindow, "focus") ;Focusing input field to remove the default text of "Username" _IEFormElementSetValue($oUserNameWindow, $g_str_DefaultUserName) _IEAction($oPasswordWindows, "focus") ;Focusing input field to remove the default text of "Password" _IEFormElementSetValue($oPasswordWindows, $g_str_DefaultPassowrd) _IEAction($oLoginButton, "click") _IELoadWait($g_obj_IE) EndFunc ;==>_EnterLoginDetails Func _NavigateToAssignLeaveAndFillData() _IELinkClickByText($g_obj_IE, "Assign Leave") _IELoadWait($g_obj_IE) Local $_obj_EmployeeNameInput = _IEGetObjById($g_obj_IE, "assignleave_txtEmployee_empName") Local $_obj_leaveTypeSeceltor = _IEGetObjById($g_obj_IE, "assignleave_txtLeaveType") Local $_obj_FromDateSelector = _IEGetObjById($g_obj_IE, "assignleave_txtFromDate") Local $_obj_ToDateSelector = _IEGetObjById($g_obj_IE, "assignleave_txtToDate") Local $_obj_AssignButton = _IEGetObjById($g_obj_IE, "assignBtn") _IEAction($_obj_EmployeeNameInput, "Focus") ; Focus is needed to "delete" the default grayed out text _IEFormElementSetValue($_obj_EmployeeNameInput, $g_str_EmployeeName) _IEAction($_obj_EmployeeNameInput, "click") _IEAction($_obj_leaveTypeSeceltor, "Focus") ;Focus is needed to Activate the option selecot _IEFormElementOptionSelect($_obj_leaveTypeSeceltor, $g_str_LeaveType, 1, "byText") _IEFormElementSetValue($_obj_FromDateSelector, $g_str_FromDate) _IEFormElementSetValue($_obj_ToDateSelector, $g_str_ToDate) _IEAction($_obj_AssignButton, "click") ;Clicks the Assign Button in Assign leave window $strHtmlBody = _IEBodyReadText($g_obj_IE) ClipPut($strHtmlBody) EndFunc ;==>_NavigateToAssignLeaveAndFillData I would appreciate if someone could give me a hint or code snippet to put me on the right track how I should approach this issue to catch these error messages.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now