Question
cognizant
US
Last activity: 21 Jun 2020 19:34 EDT
how to get information from getAttribute method in Openspan Robotic studio
how to get information from getAttribute method in Openspan Robotic studio e.g. text box appeared in the webpage. I want to access style attribute, which contains color , font etc and I am interested in getting color of font.
***Moderator Edit-Vidyaranjan: Updated Platform Capability***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
US
I am not sure what you mean. The GetAttribute method accepts an "attributeName" as an input. Given a text box like the password field at training.openspan.com with the following HTML;
<input name="user_pass" class="input_text" id="user_pass" onkeyup="return checkLengthP();" type="password" size="50" placeholder="Password">
if you passed "size" to that method, it returns 50 as expected.
cognizant
US
How about style, My application contains border information like color in it. I tried to retrieve it but it gives me an object I don't how to retrieve info from object.
Pegasystems Inc.
US
I would need to see a specific example. Can you post screenshots of your control and it's InnerHtml and then your automation?
cognizant
US
<INPUT Style"BORDER-TOP:red 2px solid;BORDER-BOTTOM:red 2px solid;BORDER-LEFT:red 2px solid;BORDER-RIGHT:red 2px solid;" name="abc" ID="abc" maxLength="15" align="LEFT" size=15>
Pegasystems Inc.
US
I am no HTML expert, but "Style" doesn't look like an attribute. It doesn't follow the pattern attribute=value. Perhaps that is the problem. If you just need the stuff after the word style, you might use a RegEx on the InnerHTML of the control.
cognizant
US
I see ... This is the only content I got from the source code(in internet explorer), when I am trying to get name it is coming out very well. but style is coming as System._Com object. Is not there any way in openspan to read that.... I tried using outterhtml or inner html and everything... but not happening for me... Please confirm if there is any way to get output from system._com object.
Pegasystems Inc.
US
I would use a RegEx on the InnerHtml. Here;s a script you can paste into the script container. Just be sure to add a using statement at the top for System.Text.RegularExpressions;
public string getStyle(string innerHtml)
{
/// <summary>
/// Regular expression built for C# on: Wed, Dec 11, 2019, 06:09:09 AM
/// Using Expresso Version: 3.0.5854, http://www.ultrapico.com
///
/// A description of the regular expression:
///
/// Style".+"
/// Style"
/// Any character, one or more repetitions
/// "
///
///
/// </summary>
Regex regex = new Regex(
"Style\".+\"",
RegexOptions.CultureInvariant
| RegexOptions.Compiled
);
//// Capture the first Match, if any, in the InputText
Match m = regex.Match(innerHtml);
return m.ToString();
}
cognizant
US
After long time, I got chance to work on this story. I created it as script and try to run and observed that outerhtml is not giving style information when it is running in debug mode, always I have to deploy the build and run on runtime. Is there additional settings in Pega studio to work in debug mode.
Pegasystems Inc.
US
I don't really understand what you mean. Can you put together an example solution and attach it to the post?