question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WinAppDriver crashes when I call element.Text

See original GitHub issue

I use element.FindElementsByXPath(“//*”) to get all child elements of a message box dialog. Then when I go through the element list calling subElement.Text on each causes WinAppDriver to crash on 4th sub element. I can see that the correct GET …/text is called but that kills WinAppDriver .exe. My application is a Windows Forms app that calls MessageBox.Show to show a message box dialog.

My test code is

    [TestMethod]
    public void MessageBox()
    {
      var capabilities = new DesiredCapabilities();
      capabilities.SetCapability("app", @"D:\MessageBoxSample\bin\Debug\MessageBoxSample.exe");

      var driver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), capabilities);

      var window = driver.FindElementByAccessibilityId("Form1");
      var button = window.FindElementByAccessibilityId("button1");
      button.Click();

      var messageBox = window.FindElementByClassName("#32770");
      var elements = messageBox.FindElementsByXPath("//*");

      foreach (var element in elements)
      {
        var str = element.Text;
      }
    }

You can find the MessageBoxSample.exe here MessageBoxSample.zip

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jaska45commented, Apr 25, 2018

Thanks. I can wait for the next version. The purpose of calling Text attribute of each element is just to collect the strings that are present on the UI at that moment. I am writing a localization testing tool. Previously be used UI automation on Windows but now studing if we can switch to WebDriver because we need use it anyway with web and mobile applications.

I am happy that you fix this because it is quite common that application just call Message.Show with one parameter like in my sample.

    private void button1_Click(object sender, EventArgs e)
    {
      MessageBox.Show("This is a sample");
    }

I tested a case when I also pass Caption and it indeed works.

0reactions
Purushotham230commented, Mar 7, 2021

Hi @timotiusmargo,
i would like to get a text from an app from the username field after sending keys to my project login username field, Send keys are working, but I’m unable to get a text from it. I’m used getText(), and also .getAttribute(“Value.Value”) , but both are not working. do you know any other way to get a text? Otherwise, is there any way to verify username fields without getting a text from it and make assertions??

Read more comments on GitHub >

github_iconTop Results From Across the Web

WinAppDriver crashes when I call element.Text · Issue #405
I use element.FindElementsByXPath("//*") to get all child elements of a message box dialog. Then when I go through the element list calling ...
Read more >
Winappdriver is crashed during UITest execution
I am testing desktop application and running UI test on CI pipeline. This error occurs randomly: TearDown : OpenQA.Selenium.
Read more >
How To Automate Desktops Apps Using WinAppDriver
This blog deep dives by telling you How To Automate Desktops Apps Using WinAppDriver. It also leverages WinAppDriver on HyperExecute Cloud ...
Read more >
UWP App Crash when inspecting the element using ...
we are trying to automate the uwp app using the Appium. we are using the winappdriver for same. we all automated the app...
Read more >
Appium, WinAppDriver and UI testing - My Memory
WinAppDriver is a Microsoft driver that Appium calls into via it's API. ... will display and then on dispose, it quits and closes....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found