microsoft / WinAppDriver

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

Unable to capture the VS .net objects using winapp driver #2024

Open satishh107 opened 4 weeks ago

satishh107 commented 4 weeks ago

Trying to automate visual studio .net application using winapp driver .

Installed appium.webdriver.package.

Steps to automate on VS.net Click on-- File-->New-->Project

Steps to reproduce the issue: 1)Create a project (Unit test project .net framework) 2) add below code 3) run the test

sing Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium.Appium; using OpenQA.Selenium.Appium.Windows; using System; using System.Threading;

namespace Mstest { [TestClass] public class UnitTest1 { [TestMethod] public void TestMethod1() { System.Diagnostics.Process.Start (@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe"); AppiumOptions options = new AppiumOptions(); options.AddAdditionalCapability("app", @"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe"); options.AddAdditionalCapability("deviceName", "WindowsPC");

        var driver = new WindowsDriver<WindowsElement>
         (new Uri("http://127.0.0.1:4723"), options);
        Thread.Sleep(3000);
        driver.FindElementByName("Continue _without code").Click();
        driver.FindElementByXPath("//*[@ClassName='MenuItem'][@Name='Edit']").Click();
        driver.FindElementByXPath("//*[contains(@Name,'Edit')]").Click();
        driver.CloseApp();
    }
}

}

Error: POST /session/359EF938-0771-4718-9545-B4B6FC4E58E3/element HTTP/1.1 Accept: application/json, image/png Content-Length: 49 Content-Type: application/json;charset=utf-8 Host: 127.0.0.1:4723 User-Agent: selenium/3.141.0 (.net windows)

{"using":"name","value":"Continue _without code"} HTTP/1.1 200 OK Content-Length: 102 Content-Type: application/json

{"sessionId":"359EF938-0771-4718-9545-B4B6FC4E58E3","status":0,"value":{"ELEMENT":"7.11380.59133445"}}

========================================== POST /session/359EF938-0771-4718-9545-B4B6FC4E58E3/element/7.11380.59133445/click HTTP/1.1 Accept: application/json, image/png Content-Length: 2 Content-Type: application/json;charset=utf-8 Host: 127.0.0.1:4723 User-Agent: selenium/3.141.0 (.net windows)

{} HTTP/1.1 200 OK Content-Length: 63 Content-Type: application/json

{"sessionId":"359EF938-0771-4718-9545-B4B6FC4E58E3","status":0}

==========================================

POST /session/359EF938-0771-4718-9545-B4B6FC4E58E3/element HTTP/1.1 Accept: application/json, image/png Content-Length: 68 Content-Type: application/json;charset=utf-8 Host: 127.0.0.1:4723 User-Agent: selenium/3.141.0 (.net windows)

{"using":"xpath","value":"//*[@ClassName='MenuItem'][@Name='Edit']"} HTTP/1.1 404 Not Found Content-Length: 139 Content-Type: application/json

{"status":7,"value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters."}}

liljohnak commented 4 weeks ago

driver.FindElementByXPath("//*[@ClassName='MenuItem'][@Name='Edit']").Click() Requires the element to be enabled and clickable. Possible solution?: Use FindElements and await the existence of the first element. Then click the control's boundingbox center.

satishh107 commented 4 weeks ago

driver.FindElementByXPath("//*[@ClassName='MenuItem'][@Name='Edit']").Click() Requires the element to be enabled and clickable. Possible solution?: Use FindElements and await the existence of the first element. Then click the control's boundingbox center.

Sorry, It didnt work.