Question
Accenture
IN
Last activity: 6 Nov 2018 20:02 EST
excutescript/invoke script
Hi Team,
Can you pls do a small login automation for the below webpage
https://www.tutorialspoint.com/angularjs/angularjs_login_application.htm"
**Moderation Team has archived post**
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
US
Button1 injects the JavaScript onto the webpage. Button2 sets the text of each text field (username and password) and then invokes the function that I injected. I pass the HTML id of the web control so that I can find it through JavaScript and raise an event on the element. Button3 clicks the login button.
I had to first investigate the element with the F12 Developer Tools in IE11. I found the events attached to the element and raised these events (I only needed an 'input' event in this case).
function raiseEvent(htmlId) {
var target = document.getElementById(htmlId);
var eventObject = document.createEvent("Event");
eventObject.initEvent('input', true, false);
target.dispatchEvent(eventObject);
}
Accenture
IN
Can you please attach the automation.
Pegasystems Inc.
US
The PDN does not allow solutions to be attached to Posts. Is there something that you are confused about?
radial
IN
Hi Vegam,
please give clarification on use of javascript in Automation.
Steps to use javascript:
1.Start Interrogation(launch/open login page)
2.Click on F12 button from keyboard and click on Debugger tab to see javascript & html code of login page.
3.Find which javascript method we want to use in Automation.
Can you see the method which i want to use:
Hi Vegam,
please give clarification on use of javascript in Automation.
Steps to use javascript:
1.Start Interrogation(launch/open login page)
2.Click on F12 button from keyboard and click on Debugger tab to see javascript & html code of login page.
3.Find which javascript method we want to use in Automation.
Can you see the method which i want to use:
EX: function checkLoginName (userCode)
{
if (userCode.value.length == 0 )
{
userCode.focus();
alert("\n Please enter Username.\n");
return false;
}
if (userCode.value.length > 16)
{
userCode.focus();
alert("\n Length of Username cannot exceed 16 characters.\n");
return false;
}
if (userCode.value.indexOf(" ") > -1)
{
userCode.focus();
alert("\n Login name cannot have spaces or blanks.\n");
return false;
}
if ( (userCode.value.indexOf("'") > -1) || (userCode.value.indexOf("\"") > -1) )
{
userCode.focus();
alert("\n Username cannot have single or double quotes.\n");
return false;
}
return true;
}
4.Now came back to Openspan Studio and open Automation1.os
5.Please confirm above steps as correct or not and tell me remaining steps to use that javascript function of "checkLoginName (userCode)" in my automation.
Another doubt,how you get two parameters ExecuteScript method. i mean you have given two parameters like (i)Function name,(ii)javascript (is mandatory to execute that function?).
Note: i tried to get two parameterised ExecuteScript method but can't get.
Please find two attachments to get more information to clarify the same.
Thanks.
-
Ashok Kannan
Tata Consultancy Services (TCS)
CA
Hi,
You can add as many parameters in the javascript and pass them in ExecuteScript method.
E.g. function checkLoginName (userCode, userpass)
{
// your logic
}
Thanks,
Antara
radial
IN
Anyone confirm that procedure to use JavaScript function in Automation.
Thanks