Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access popup window outside of WinAppDriver Appium WinForm in C#? #1984

Open
jainchengithub opened this issue Mar 13, 2024 · 5 comments

Comments

@jainchengithub
Copy link

jainchengithub commented Mar 13, 2024

**Hi,

My win app is "Gyro Multi Vendor SPEAR - Version 6.20.14". normal WinAppDriverUIRecorder XML Nodes has my win app included, so I can access.**

<UiTask task="Inspect" x="154" y="619">

<Pane LocalizedControlType="pane" ClassName="#32769" Name="Desktop 1" AutomationId="" x="0" y="0" width="3840" height="2160" Pos=""/>

<Window LocalizedControlType="window" ClassName="WindowsForms10.Window.8.app.0.29531c8_r8_ad1" Name="Gyro Multi Vendor SPEAR - Version 6.20.14  -Development Version" AutomationId="MainControl" x="1155" y="495" width="1530" height="1110" Pos="4"/>

<Window LocalizedControlType="window" ClassName="WindowsForms10.Window.8.app.0.29531c8_r8_ad1" Name="Default Tool Parameters" AutomationId="ParametersDefaultsForm2" x="1304" y="650" width="1233" height="800" Pos=""/>

</UiTask>

But I have a pop up window which does not include my win app name, how to use FindElementByAccessibilityId or FindElementByName etc. to access?

<UiTask task="Inspect" x="374" y="847">

<Pane LocalizedControlType="pane" ClassName="#32769" Name="Desktop 1" AutomationId="" x="0" y="0" width="3840" height="2160" Pos=""/>

<Window LocalizedControlType="dialog" ClassName="#32770" Name="Browse For Folder" AutomationId="" x="1670" y="804" width="978" height="888" Pos="4"/>

</UiTask>

my C# code to declare sessionWinForm:

public class SPEAR_MVTest
{
    static WindowsDriver<WindowsElement> sessionWinForm;
    static private int client_type = 0;

    [ClassInitialize]
    public static void Init(TestContext testContext)
    {
        AppiumOptions dcWinForms = new AppiumOptions();
        dcWinForms.AddAdditionalCapability("app",
        "@C:\Program Files\Gyrodata\Gyro MV SPEAR Dev\Gyro MV Spear.exe");  
        sessionWinForm = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), dcWinForms);

    }
}

I use "var folder_win = sessionWinForm.FindElementByName("Browse For Folder");"
error: OpenQA.Selenium.WebDriverException: An element could not be located on the page using the given search parameters.

@anunay1
Copy link

anunay1 commented Mar 14, 2024

You need to create a root session and then switch to the pop up window.

@jainchengithub
Copy link
Author

How to create a root session? Do you have the code to do it?

Thanks!

@anunay1
Copy link

anunay1 commented Mar 14, 2024

@jainchengithub
Copy link
Author

Hi, if I want to open a excel file and save the test result (pass/fail) to related cell value, where can I find the sample code?

@Shakevg
Copy link

Shakevg commented Mar 29, 2024

Hi, if I want to open a excel file and save the test result (pass/fail) to related cell value, where can I find the sample code?

Get test result value for mstest (something the same you can find for other runners): https://stackoverflow.com/questions/13201566/how-to-get-test-result-status-from-mstest
Working with Excel https://www.mycplus.com/tutorials/csharp-programming-tutorials/read-write-excel-files-csharp/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants