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 not finding elements

See original GitHub issue

Hi,

I am investigating a new toolset for our automation, we were previously using white which is now deprecated and we use Selenium for our web based tests so this seems a sensible tool. However I am really struggling to get the any elements to be identified after the program launches, I’ve seen posts about desktop sessions etc but the suggested resolution there is also deprecated and I can’t find any information on the alternative.

This is the test I have it’s fairly basic just launching the app and verifying the text of the title bar of the login screen, running the steps through postman it all works fine so not really sure what’s wrong.

` public class TestQdaq { [Test] public void FindElementTest() { var driver = StartApplication(); var elementFound = driver.FindElementByAccessibilityId(“TitleBar”);

        Assert.IsTrue(elementFound.Text == "Username");
        //elementFound.SendKeys("9999");
      
        driver.CloseApp();
    }



    public WindowsDriver<WindowsElement> StartApplication()
    {
                   
        //Working code for other apps below here:

        var capabilities = new AppiumOptions();
        
        //capabilities.AddAdditionalCapability(MobileCapabilityType.App, "C:\\Program Files\\QDAQ\\QDAQ.exe");
        capabilities.AddAdditionalCapability(MobileCapabilityType.App, @"C:\Program Files\ODM Mapper\ODM Mapper.exe");
        capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Windows");
        capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "NOELF-L-W10");
        
        //Start Driver
        //var driver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities);
        var _appiumLocalServer = new AppiumServiceBuilder().UsingAnyFreePort().Build();

        _appiumLocalServer.Start();

        var driver = new WindowsDriver<WindowsElement>(_appiumLocalServer, capabilities);
        Thread.Sleep(5000);

        return driver;

        //Close Driver
        //driver.Close();
        //driver.Dispose();
    }
}

}`

Appium log [info] [WinAppDriver] [STDOUT] ========================================== [info] [WinAppDriver] [STDOUT] POST /wd/hub/session HTTP/1.1 [info] [WinAppDriver] [STDOUT] Accept: application/json, / [info] [WinAppDriver] [STDOUT] Connection: close [info] [WinAppDriver] [STDOUT] Content-Length: 131 [info] [WinAppDriver] [STDOUT] Content-Type: application/json; charset=utf-8 [info] [WinAppDriver] [STDOUT] Host: 127.0.0.1:4724 [info] [WinAppDriver] [STDOUT] User-Agent: appium [info] [WinAppDriver] [STDOUT] [info] [WinAppDriver] [STDOUT] [info] [WinAppDriver] [STDOUT] HTTP/1.1 200 OK [info] [WinAppDriver] [STDOUT] Content-Length: 152 [info] [WinAppDriver] [STDOUT] Content-Type: application/json [info] [WinAppDriver] [STDOUT] [info] [WinAppDriver] [STDOUT] {“sessionId”:“04A152BD-2727-4167-94E8-BB700A79EFC0”,“status”:0,“value”:{“app”:“C:\Program Files\ODM Mapper\ODM Mapper.exe”,“platformName”:“Windows”}}[info] [WinAppDriver] [STDOUT] [info] [WinAppDriver] [STDOUT] [info] [WinAppDriver] [STDOUT] ========================================== [info] [WinAppDriver] [STDOUT] POST /wd/hub/session/04A152BD-2727-4167-94E8-BB700A79EFC0/element HTTP/1.1 [info] [WinAppDriver] [STDOUT] Accept: application/json, / [info] [WinAppDriver] [STDOUT] Connection: close [info] [WinAppDriver] [STDOUT] Content-Length: 47 [info] [WinAppDriver] [STDOUT] Content-Type: application/json; charset=utf-8 [info] [WinAppDriver] [STDOUT] Host: 127.0.0.1:4724 [info] [WinAppDriver] [STDOUT] User-Agent: appium [info] [WinAppDriver] [STDOUT] [info] [WinAppDriver] [STDOUT] [info] [WinAppDriver] [STDOUT] HTTP/1.1 404 Not Found [info] [WinAppDriver] [STDOUT] Content-Length: 139 [info] [WinAppDriver] [STDOUT] Content-Type: application/json [info] [WinAppDriver] [STDOUT] [info] [WinAppDriver] [STDOUT] {“status”:7,“value”:{“error”:“no such element”,“message”:“An element could not be located on the page using the given search parameters.”}}

Apologies for the very novice post and if it’s in the wrong place, I am following a tutorial and it’s not got any great depth to troubleshooting and my googling has returned nothing

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Aradeskcommented, Jul 2, 2020

Hi, It seems like you run Appium locally , can you try to connect directly to the winappdriver ? (get rid of “/wd/hub”). Also, did you manage to use that setup on other basic apps like calc ?

In your logs you should have {"using":"accessibility id","value":"TitleBar"} when calling “/element” but i don’t see it anywhere. (though i see Content-Length: 47 so it might have been sent)

Either you have an issue in your Appium/WinAppDriver setup or the title bar you seach in your app isn’t quite what we would expect.

0reactions
liljohnakcommented, Jan 27, 2023

Unsure exactly what you are doing. (Show code or driver log for a more specific response.) You probably have windows/popups generated outside your app. You may need to make a root session to find them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

winappdriver couldn't find element using
instead of sendkeys, try clicking the element by using click() function. See first your element is interactable. element.enabled == true, ...
Read more >
Its impossible to identify when an element is visible or not
I am having a similar issue. Dev Ex controls which are making an element not visible in real time, however the windows element...
Read more >
Inspecting UI Elements for WinAppDriver automation using ...
WinAppDriver supports various locators to find UI element, and then drive then to perform actions, below table shows all the supported locators.
Read more >
WinAppDriver is not able to locate elements on Desktop ...
I'm trying to automate a workflow with MS Teams and I'm using WinAppDriver. I'm able to bring up Teams and WinAppDriver using the...
Read more >
WinAppDriver could not find element sometimes
WinAppDriver sometimes find element, sometimes no... I try to log my elements List size, and when I run my test sometimes it return...
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