Winappdriver: WindowsDriver<WindowsElement> app not getting update pagesource

Created on 24 Mar 2018  路  9Comments  路  Source: microsoft/WinAppDriver

Hi,

I am using winAppDrive to automation WPF application. on start of out application it show loading page and after loading necessary file actual WPF application load after 50 to 60 seconds.

But when I check pagesource, I only see the source of loading page.

I am automating USD (unified service desk app) Dynamics 365 APP.

Please guide me how do I refresh WindowsDriver app value with latest page code.

Regards,
-Dhaval M.

Most helpful comment

I was able to solve this issue with below line

app.SwitchTo().Window(app.WindowHandles[0]);

All 9 comments

I have also create desktop session like below

` DesiredCapabilities appDesktop = new DesiredCapabilities();

        appDesktop.SetCapability("app", "Root");
        WindowsDriver<WindowsElement>  DesktopSession = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appDesktop);`

planning to iterate thru windows using windowshandlers but I dont see any windowhandler under desktop.

Can you guide me how can I move from one app window to other app window.

I was able to solve this issue with below line

app.SwitchTo().Window(app.WindowHandles[0]);

Hi @dhaval-mistry,

I'm glad you figured out the way to switch to the active window. Bear in mind that your solution above is valid only when the application top window appears. In other word, you may need to have a fixed delay (wait) or write a logic to poll for certain UI condition. And just to be clear, WinAppDriver only allows existing application session to switch to another window belonging to the same application (same process Id).

Hi @timotiusmargo

Thanks for your suggestion & inputs. I am looking into it only. how do I put random wait condition. currently I am putting like 1 min but sometime it took 30 sec or more than 1 min. to appear window.

Can you guide me how can I put random time? (process start continue as soon as screen or control available) generic code. do we have any sample code available?

When I see app.pagesource i received very big XML file. how do I generate specific xpath for some control? do you know any free tool which help me to generate xpath?

Hi @dhaval-mistry ! I'm also going create automation framework by WinAppDriver for USD app, maybe we can communicate and discuss some issues?

Hi @timotiusmargo
Currently, I can't get access to the element when an app was launched by WinAppDriver and got next error(see attached).
error.txt

@ant0908 , Glad that I found some partner during USD automation journey

@dhaval-mistry Yeah! Glad to hear! how are you doing with creating automation framework by WinAppDriver for USD app? What app do you use for inspecting UI elements?

I use, inspect.exe. part of windows sdk

https://msdn.microsoft.com/en-us/library/windows/desktop/dd318521(v=vs.85).aspx

@dhaval-mistry

For how to write xpath expressions, u can refer to the following: https://devhints.io/xpath. To check if the specific xpath expression is correct, one suggestion I have is to use the XPath evaluation plugin for eclipse https://github.com/stoupa91/eclipse-xpath-evaluation-plugin. You can paste in the entire page source and then put in your xpath expression to evaluate.

As to dynamically check for when the new window appears you can easily poll for the existence of the window: example:
while (DesktopSession.findElementByAccessibilityId("automationId").size() == 0) { Thread.sleep(Time in milliseconds); }

Hope this helps!

Was this page helpful?
0 / 5 - 0 ratings