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();
}
Hi Amer,
The Widgets should contain this value you add to the display.
But keep in mind they only happen if you first shown your UI first and the Widgets are part of this build UI.
To access the values, an event handler needs to be present. Either on change of the value of the textbox or on a push of the button. Then the value in the Widget in question will be present.
Of course I don't full see the complete implementation. But the previous conditions need to be present before the Widgets get filled in.
Hope this helps investigating the issue you having.
Hi Thomas,
On the steps before hand is the ui is displayed and the user creates more textboxes as is required and after filling in as many as needed a button is pressed after this button I am trying to collect all widgets in a loop afterwards I am only checking the widgets that are textboxs and if they are a textbox I am trying to get the text which does not seem possible.