Hi Dojo Community,
I was wondering if it is possible to grab the text from text boxes widgets that are created during automation ?
I have tried a for loop for the widgets as so:
foreach(Widget a in AWS.Widgets)
{
if (skip != 0)
{
if (a.Type == UIBlockType.TextBox)
{
engine.Log(a.Text);
}
skip++;
}
}
Thanks in advance
Hi Amer,
That should indeed be possible. I've tried the same as you and it works as expected. Could you verify:
- if you are using the latest version of the Skyline.DataMiner.Utils.InteractiveAutomationScriptToolkitExample NuGet?
- The variable 'a' within your code is of Type Widget still, could you try casting it specifically to a Textbox to make sure we access the Text property?
Example below:
- The 'Add TextBox' button will dynamically add a textbox to your dialog.
- The 'Print Status' button will retrieve and show all current text values within the textboxes within your dialog.
internal sealed class Testdialog : Dialog
{
public Testdialog(IEngine engine) : base(engine)
{
BtnAdd.Pressed += (sender, args) => AddWidget(new TextBox(String.Empty), ++Row, 0);
BtnPrintStatus.Pressed += (sender, args) =>
{
StringBuilder sb = new StringBuilder();
foreach (TextBox widget in this.Widgets.OfType<TextBox>())
{
sb.AppendLine("Text: " + widget.Text);
}Status.Text = sb.ToString();
};AddWidget(BtnAdd, Row, 0);
AddWidget(BtnPrintStatus, Row, 1);
AddWidget(Status, ++Row, 0);
}public int Row { get; set; }
public Button BtnAdd { get; } = new Button("Add TextBox");
public Button BtnPrintStatus { get; } = new Button("Print Status");
public Label Status { get; } = new Label();
}