FlaUI / FlaUI.WebDriver

MIT License
42 stars 8 forks source link

[Bug] An element is off-screen when two or more windows are opened after an application launch #57

Open NeONRAcE opened 5 months ago

NeONRAcE commented 5 months ago

Hi guys! I faced a problem while was trying to interect with an element

Pre-conditions

I have an app that launches 2 windows after its start (the second one is not actually a window because the window_handle is the same so it is like a part of the main window). Here is an example: image

The "Select patient" window appears after the main window immediately.

Steps to reproduce from my side

  1. I'm filling in the patient's data and pressing OK
  2. The second window closes automatically (the window_handle is the same as well as the current_window_handle)
  3. I'm trying to interact with any element on the main form
  4. Facing the error below: response = {'status': 400, 'value': '{"value":{"error":"element not interactable","message":"Element with ID 2f7955c3-640c-4f2c-ab35-c477c122de49 is off screen","stackTrace":""}}'}

I also noticed that all elements have x:0, y:0 position, but they are enabled (checked with is_enabled method)

What can I do to fix the error above? Thank you! Please feel free to ask any details

Add.Info

I used to use WinAppDriver and everything worked correctly there. The needed element had a correct position

aristotelos commented 5 months ago

This behavior is because the element's property IsOffscreen is true. See the FlaUI.WebDriver source code.

This property is a Windows Automation property. Note the following lines:

The value of the property is not affected by occlusion by other windows

So could it be that the element is not scrolled into view? (Note that FlaUI.WebDriver also attempts to scroll the element into view as dictated by the WebDriver standard.)

Here is what the WebDriver2 standard says about "element not interactable".

If element's container is still not in view, return error with error code element not interactable.

I need to dive into this further with an attempt to reproduce it before I can say whether this is a bug, but if WinAppDriver behaves differently it would be nice to at least have the option to have WinAppDriver-compliant behavior.

NeONRAcE commented 5 months ago

https://github.com/FlaUI/FlaUI.WebDriver/assets/17156684/707b8581-0307-4cfa-8179-b5a4e4e758cb

Here is a small video describing my problem. The application launches and has two windows at the start. I successfully interact with the second window, but after it closes -- I can't interact with the main window. From my experience, it looks like the focus of the driver is still on the second window, but the process is general for both windows.

As you described above, I don't see any way to scroll anything because there aren't any scrolls at all.

P.S. As I mentioned -- the problem is weird because the needed button has X and Y coordinates set to 0, 0. Even if the IsOffscreen property is set to true -- the coordinates must be different from 0, 0

grokys commented 4 months ago

@NeONRAcE you might want to try using inspect.exe to take a look at the raw automation properties after you've manually triggered the repro.