microsoft / WinAppDriver

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

How to use the below element using webdriverIO #1853

Open diptilenka opened 1 year ago

diptilenka commented 1 year ago

MicrosoftTeams-image (12) I have attached my application view for About tab displayed for not using winappdriver with WebdriverIO.

await (await (await $('//*[@automationId=\"AboutTb\"]')).shadow$('//RadioButton[@Name=\"About\"]')).waitForDisplayed(); I have written to detect the About link in my windows custom application, but it always failed to locate the element. Am i doing something wrong.

Shakevg commented 1 year ago

diptilenka Per your screen it should be something like await (await (await $('//*[@automationId=\"AboutTb\"]')).shadow$('//*[@Name=\"About\"]')).waitForDisplayed();

diptilenka commented 1 year ago

Screenshot 2023-01-20 154132 Now it shows this error @Shakevg

Shakevg commented 1 year ago

@diptilenka Sorry, github removed char after "//". I fixed code above, try one more time

diptilenka commented 1 year ago

@diptilenka Sorry, github removed char after "//". I fixed code above, try one more time

Screenshot 2023-01-20 175935 @Shakevg This now showing

Shakevg commented 1 year ago

diptilenka Unfrotantly I don't work with webdriverIO. Could you please post screen from Inspector.exe with the control that has this XPath: @automationId=\"AboutTb\" Why do you use @automationId but not @AutomationId

diptilenka commented 1 year ago

diptilenka Unfrotantly I don't work with webdriverIO. Could you please post screen from Inspector.exe with the control that has this XPath: @automationId="AboutTb" Why do you use @automationId but not @AutomationId

I post in webdriverIO Gitter channel too, but no response till now. Whether it is automationId or AutomationId, it has same issues.

anunay1 commented 1 year ago

have you tried with any other locator?

diptilenka commented 1 year ago

have you tried with any other locator?

e.g ?

anunay1 commented 1 year ago

The automation id is not there for "about" that is the reason you are getting the error, my bad i missed it, by other i mean by name.

diptilenka commented 1 year ago

The automation id is not there for "about" that is the reason you are getting the error, my bad i missed it, by other i mean by name.

Tried that too, still no success, does you are having any working repo to try with. Seems like webdriverIO+winappdriver.

anunay1 commented 1 year ago

Unfortunately I have not worked wedriver.io but may be able to help you over the call

diptilenka commented 1 year ago

Unfortunately I have not worked wedriver.io but may be able to help you over the call

Thats fine for me, lets meet and try to solve it. how to connect with you ?

anunay1 commented 1 year ago

Send me a teams invite tomorrow at 8:30 PM IST.

diptilenka commented 1 year ago

Send me a teams invite tomorrow at 8:30 PM IST.

sure

diptilenka commented 1 year ago

@anunay1 Can you have time in the morning today :)

anunay1 commented 1 year ago

No

diptilenka commented 1 year ago

No

ok on evening 5 PM IST

anunay1 commented 1 year ago

No only after 8 PM

diptilenka commented 1 year ago

ok will ping you after 8 PM

diptilenka commented 1 year ago

@anunay1 are you available now?

anunay1 commented 1 year ago

@anunay1 are you available now?

yap

diptilenka commented 1 year ago

Could you please send me the invite ?

anunay1 commented 1 year ago

Could you please send me the invite ?

sent it to anunayathakur1@gmail.com(it is there in the profile)

diptilenka commented 1 year ago

check now

diptilenka commented 1 year ago

Could you please send me the invite ?

sent it to anunayathakur1@gmail.com(it is there in the profile)

Could you please send me the invite ?

sent it to anunayathakur1@gmail.com(it is there in the profile)

Could you please send me the invite ?

sent it to anunayathakur1@gmail.com(it is there in the profile)

Thanks for the help @anunay1 , but still in C# also am unable to get those elements to clickable. :(

anunay1 commented 1 year ago

What's the error? And what kind of application is it win32, wpf or uwp

diptilenka commented 1 year ago

Message:  Test method designerautomation.UnitTest1.TestMethod1 threw exception: OpenQA.Selenium.WebDriverException: An element could not be located on the page using the given search parameters.

Stack Trace:  RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) RemoteWebDriver.FindElement(String mechanism, String value) AppiumDriver1.FindElementByXPath(String xpath) UnitTest1.TestMethod1() line 43

@anunay1 The appp is x64 WPF application running on .NET framework 4.8 it uses MahApps.Metro 1.6.2 for the controls

anunay1 commented 1 year ago

Can you share the code? That's weird

diptilenka commented 1 year ago

@anunay1 ` using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium; using OpenQA.Selenium.Appium; using OpenQA.Selenium.Appium.Windows; using OpenQA.Selenium.Remote; using System; using System.Threading;

namespace designerautomation { [TestClass] public class UnitTest1 {

    //Appium Driver URL it works like a windows Service on your PC  
    private const string appiumDriverURI = "http://127.0.0.1:4723";
    //Application Key of your UWA   
    //U can use any .Exe file as well for open a windows Application  
    private const string calApp = "XXXXXXXX/Composer.exe";

    protected static WindowsDriver<WindowsElement> calSession;

    [TestMethod]
    public void TestMethod1()
    {
        if (calSession == null)
        {
            var appCapabilities = new AppiumOptions();
           // DesiredCapabilities appCapabilities = new DesiredCapabilities();
            //appCapabilities.SetCapability("app", calApp);
            //appCapabilities.SetCapability("platformName", "Windows");
            appCapabilities.AddAdditionalCapability("app", calApp);
            appCapabilities.AddAdditionalCapability("platformName", "Windows");
            //Create a session to intract with Calculator windows application  
            calSession = new WindowsDriver<WindowsElement>(new Uri(appiumDriverURI), appCapabilities);

            Thread.Sleep(15000);
            //Automate Button and Get answer from Calculator  

            //find by Name  
            // calSession.FindElement(By.XPath("//*[@AutomationId=\"AboutTb\"]")).Click();
            //calSession.FindElementByXPath("/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Window[@ClassName=\"Window\"][@Name=\"Designer\"]/Custom[@AutomationId=\"RecentProjectsDataControl\"]/RadioButton[@AutomationId=\"OpenOther\"]/Text[@ClassName=\"TextBlock\"][@Name=\"Open Other Document\"]").Click();

            //calSession.FindElementByName("About").Click();

        }
    }
}

}

`

anunay1 commented 1 year ago

Your code is ok can you get the page source.

diptilenka commented 1 year ago

Your code is ok can you get the page source.

Again i think we need to sit together at night ISt today to have another look ? @anunay1