microsoft / WinAppDriver

Windows Application Driver
MIT License
3.66k stars 1.4k forks source link

Cant interact with any elements on default OneNote App on Win10 #420

Open AmitVerma4HP opened 6 years ago

AmitVerma4HP commented 6 years ago

All I am trying to do is to open OneNote (cloud instance) then go to "More" (3 dots on the top right corner) and then click on "Print"

This code opens OneNote just fine public static RemoteWebDriver OpenOneNoteApp(String device_name)throws MalformedURLException, InterruptedException {

        try {
            capabilities = new DesiredCapabilities();
            capabilities.setCapability("app", "Microsoft.Office.OneNote_8wekyb3d8bbwe!microsoft.onenoteim");
            //capabilities.setCapability("appArguments", web_url);
            capabilities.setCapability("platformName", "Windows");
            capabilities.setCapability("deviceName", device_name);
            OneNoteSession = new RemoteWebDriver(new URL(WindowsApplicationDriverUrl), capabilities);
            Assert.assertNotNull(OneNoteSession);
            OneNoteSession.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
            OneNoteSession.manage().window().maximize();
            Thread.sleep(2000);
        } catch (Exception e) {
            log.info("Error opening OneNote app");
        }

        log.info("Opened First OneNoteSession successfully");   

Then "More" option throws 404.

Appium Log - [WinAppDriver] [STDOUT] {"sessionId":"0BB54A2A-893F-4909-AE8C-6F32ED287626","status":0} [debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"0BB54A2A-893F-4909-AE8C-6F32ED287626","status":0} [JSONWP Proxy] Replacing sessionId 0BB54A2A-893F-4909-AE8C-6F32ED287626 with 5bb7912b-a369-4f34-9aa5-b879f1f1a8c4 [HTTP] <-- POST /wd/hub/session/5bb7912b-a369-4f34-9aa5-b879f1f1a8c4/window/current/maximize 200 20 ms - 63 [HTTP] --> POST /wd/hub/session/5bb7912b-a369-4f34-9aa5-b879f1f1a8c4/element {"using":"name","value":"More"} [MJSONWP] Driver proxy active, passing request on via HTTP proxy [debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/5bb7912b-a369-4f34-9aa5-b879f1f1a8c4/element] to [POST http://127.0.0.1:4731/wd/hub/session/0BB54A2A-893F-4909-AE8C-6F32ED287626/element] with body: {"using":"name","value":"More"} [WinAppDriver] [STDOUT] [WinAppDriver] [STDOUT] [WinAppDriver] [STDOUT] ========================================== [WinAppDriver] [STDOUT] POST /wd/hub/session/0BB54A2A-893F-4909-AE8C-6F32ED287626/element HTTP/1.1 [WinAppDriver] [STDOUT] Accept: / [WinAppDriver] [STDOUT] Connection: keep-alive [WinAppDriver] [STDOUT] Content-Length: 31 [WinAppDriver] [STDOUT] Content-Type: application/json [WinAppDriver] [STDOUT] Host: 127.0.0.1:4731 [WinAppDriver] [STDOUT] User-Agent: appium [WinAppDriver] [STDOUT] [WinAppDriver] [STDOUT] {"using":"name","value":"More"} [WinAppDriver] [STDOUT] HTTP/1.1 404 Not Found [WinAppDriver] [STDOUT] Content-Length: 139 [WinAppDriver] [STDOUT] Content-Type: application/json [WinAppDriver] [STDOUT] [WinAppDriver] [STDOUT] {"status":7,"value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters."}} [MJSONWP] Encountered internal error running command: {"w3cStatus":400,"jsonwp":{"status":7,"value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters."}}} ProxyRequestError: Could not proxy command to remote server. Original error: 404 - {"status":7,"value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters."}}

1) I tried all methods mentioned here , thinking I may not have correct window handle but it didnt help.

2) Also printed all handles when OneNote opens it only shows oneWindows handle (which was currenthandle)

3) Also tried to open OneNote and then attached Session to it

In all above cases , I couldn't get to click on any option on OneNote.

Inspect for More option image

More option on OneNote capture

AmitVerma4HP commented 6 years ago

We got 2 workarounds to make this work. 1) Click on OneNote text surface and then go for Ctrl + P if option1 does not work then

2) Minimize and maximize OneNote app then OneNote session gets all elements control and works fine.