microsoft / WinAppDriver

Windows Application Driver
MIT License
3.7k stars 1.41k forks source link

Element not interactable. An Element command could not be completed becuase the element is not pointer- or keyboard interactable #1899

Open saurabhsule82 opened 1 year ago

saurabhsule82 commented 1 year ago

Hi,

I'm trying to automate our VPN client which a windows tray application.

I'm able to find and click the VPN client which opens up the client lists. I'm also able to find the particular client, but when I try to click it, it gives the error - Element not interactable. An Element command could not be completed becuase the element is not pointer- or keyboard interactable.

Here is the sample code:

WebElement portal = windowTray.findElementByXPath("/Pane[@Name=\"Desktop 1\"][@ClassName=\"#32769\"]/Menu[@Name=\"Context\"][@ClassName=\"#32768\"]/MenuItem[@Name=\"APMC Client 1\"]");

portal.click();

Attaching the screenshot of the actual VPN Client as well as the AccessibilityInsights of the VPN Client.

VPN Client: VPN Client Context Menu

Accessibility Insights of the VPN Client:

VPN Client Context Menu Acessibility Insight

Please note, I've redacted the actual client names.

We are unable to proceed with our automation because of this issue. Any help is really appreciated.

Thank you.

anunay1 commented 1 year ago

What is shown in inspect.exe?

Shakevg commented 1 year ago

saurabhsule82 As a workaround you can click on control center point by coordinates https://github.com/microsoft/WinAppDriver/issues/810#issuecomment-592151951

saurabhsule82 commented 1 year ago

What is shown in inspect.exe?

inspect

saurabhsule82 commented 1 year ago

saurabhsule82 As a workaround you can click on control center point by coordinates #810 (comment)

Tried, but doesn't work.

anunay1 commented 1 year ago

Can you try with any other locator?

saurabhsule82 commented 1 year ago

Trying any other locator is not an option since the automation will be dynamic and we wouldn't have the values of other locators like Annotation ID. We cannot hard code the Annotation ID either.

Shakevg commented 1 year ago

Did you see an error or did just nothing happen? Did you check visually on what place the test is clicking?

saurabhsule82 commented 1 year ago

If I try to use coordinates, it clicks at the bottom of the taskbar, near the notification chevron '^' button.

Shakevg commented 1 year ago

If I try to use coordinates, it clicks at the bottom of the taskbar, near the notification chevron '^' button.

Please post your code and control Size value:

WebElement portal = windowTray.findElementByXPath("/Pane[@name="Desktop 1"][@classname="#32769"]/Menu[@name="Context"][@classname="#32768"]/MenuItem[@name="APMC Client 1"]");
var size = portal.Size;
saurabhsule82 commented 1 year ago

If I try to use coordinates, it clicks at the bottom of the taskbar, near the notification chevron '^' button.

Please post your code and control Size value:

WebElement portal = windowTray.findElementByXPath("/Pane[@name="Desktop 1"][@classname="#32769"]/Menu[@name="Context"][@classname="#32768"]/MenuItem[@name="APMC Client 1"]");
var size = portal.Size;

Here is the code:

private static WindowsDriver windowTray = null;

public static void main(String[] args) throws Exception {

DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("app", "Root"); windowTray = new WindowsDriver(new URL("http://127.0.0.1:4723"), capabilities); windowTray.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); windowTray.findElementByXPath("/Pane[@Name=\"Desktop 1\"][@ClassName=\"#32769\"]/Pane[@Name=\"Taskbar\"][@ClassName=\"Shell_TrayWnd\"]/Pane[@ClassName=\"TrayNotifyWnd\"]/Button[@Name=\"Notification Chevron\"][@ClassName=\"Button\"]").click(); Thread.currentThread().sleep(11000); windowTray.findElementByXPath("/Pane[@Name=\"Desktop 1\"][@ClassName=\"#32769\"]/Pane[@Name=\"Notification Overflow\"][@ClassName=\"NotifyIconOverflowWindow\"]/ToolBar[@Name=\"Overflow Notification Area\"][@ClassName=\"ToolbarWindow32\"]/Button[contains(@Name,\"Conn\")]").click(); Thread.currentThread().sleep(11000); windowTray.findElementByXPath("/Pane[@Name=\"Desktop 1\"][@ClassName=\"#32769\"]/Window[@Name=\"GlobalProtect\"][@ClassName=\"#32770\"]/Button[@ClassName=\"MFCMenuButton\"]").click(); WebElement portal = windowTray.findElementByXPath("/Pane[@Name=\"Desktop 1\"][@ClassName=\"#32769\"]/Menu[@Name=\"Context\"][@ClassName=\"#32768\"]/MenuItem[@Name=\"APMC Client 1\"]"); System.out.println(portal.getSize()); System.out.println(portal.getSize().getHeight()); System.out.println(portal.getSize().getWidth());

Actions a = new Actions(windowTray); a.moveByOffset(portal.getLocation().getX(), portal.getLocation().getY()).click().build().perform();

portal.getSize().getHeight() --> 24 portal.getSize().getWidth() --> 449

portal.getLocation().getX() --> 1054 portal.getLocation().getY() --> 1201

The click happens but doesn't happen on the menu item but somewhere else on the screen. No sure where.

saurabhsule82 commented 1 year ago

Can you try with any other locator?

I tried using AutomationId as part of the xPath but the same results. It finds the element with the xPath, but on clicking the element it throws the same error - Element not interactable.