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

WinAppDriver is launching the test application endlessly when starting the test #2048

Open
bwomsm1 opened this issue Jan 27, 2025 · 18 comments

Comments

@bwomsm1
Copy link

bwomsm1 commented Jan 27, 2025

I am running the following script:

from appium import webdriver
import time
from appium.options.windows import WindowsOptions

# Desired capabilities for Windows application
desired_caps = {
    "app": "C:\\ondemandanalysis-0.3.0.36\\oda.bat",  # Path to Notepad
    "platformName": "Windows",
    "app_working_dir": "C:\\ondemandanalysis-0.3.0.36\\",
    "deviceName": "WindowsPC",  # Local machine
}
driver = webdriver.Remote(
    "http://127.0.0.1:4723/wd/hub", options=WindowsOptions().load_capabilities(desired_caps)
)

time.sleep(2)
print(driver.page_source)
driver.quit()

In order to have the windows app C:\\ondemandanalysis-0.3.0.36\\oda.bat, download it from https://drive.google.com/file/d/18qgnRtSXGh14nN0iVGCP_WEUMEkp1diR/view?usp=drive_link

Expected Behavior

Appium should launch the application once and print to screen the app elements.

Appium Server logs: https://github.com/bwomsm1/AppiumLogs/blob/master/appium_win.log

@bwomsm1
Copy link
Author

bwomsm1 commented Jan 27, 2025

@DHowett can you please help with this issue? thanks!

@bwomsm1 bwomsm1 changed the title Appium that is running windows driver test is launching the windows app endlessly Appium that is using WinAppDriver test is launching the windows app endlessly Jan 27, 2025
@bwomsm1 bwomsm1 changed the title Appium that is using WinAppDriver test is launching the windows app endlessly WinAppDriver is launching the test application endlessly when starting the test Jan 27, 2025
@bwomsm1
Copy link
Author

bwomsm1 commented Jan 27, 2025

I can also say that when trying to run exe file instead of bat file I also see the problem

@anunay1
Copy link

anunay1 commented Jan 27, 2025

if you are using a bat file you need to create a root session and acquire a session on opened window.

@bwomsm1
Copy link
Author

bwomsm1 commented Jan 27, 2025

if you are using a bat file you need to create a root session and acquire a session on opened window.

@anunay1 Can you detail more what do you mean?

@anunay1
Copy link

anunay1 commented Jan 27, 2025

check #1157

@anunay1
Copy link

anunay1 commented Jan 27, 2025

You need to create a root session and then create a session with opened application. It's like you do with splash application.

@bwomsm1
Copy link
Author

bwomsm1 commented Jan 27, 2025

You need to create a root session and then create a session with opened application. It's like you do with splash application.

@anunay1 How do I find my appTopLevelWindow hex number? I used the Inspect.exe app, but the hex hwnd value is changing all the time? each session is showing a differnt hex

@anunay1
Copy link

anunay1 commented Jan 28, 2025

@bwomsm1
Copy link
Author

bwomsm1 commented Jan 28, 2025

Check

https://github.com/anunay1/SampleWADPython

Thanks @anunay1 it helped; I just wonder,
When I print to console driver.page_source I am not able to see my app elements.
I ran the following 3 processes as Administrator:

  1. IDE
  2. Appium server
  3. Tested app

What am I missing?

(Also when running Inspect.exe as admin I cannot see my app elements)

@bwomsm1
Copy link
Author

bwomsm1 commented Jan 28, 2025

Image

These are the only elements which I can see in Inspect.exe

@anunay1
Copy link

anunay1 commented Jan 28, 2025

Then there are no automation properties implemented in the application.

@anunay1
Copy link

anunay1 commented Jan 28, 2025

If the application is under your control ask them to implement automation properties

@bwomsm1
Copy link
Author

bwomsm1 commented Jan 28, 2025

If the application is under your control ask them to implement automation properties

thanks, going to ask the app devs

@bwomsm1
Copy link
Author

bwomsm1 commented Jan 28, 2025

@anunay1 I am trying to understand something.
I tried the following simple test,
I created the following simple app:

import javax.swing.*;

public class AccessibleSwingApp {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            JFrame frame = new JFrame("Accessible Swing App");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(400, 200);

            JPanel panel = new JPanel();

            // Add a button with accessible properties
            JButton button = new JButton("Submit");
            button.getAccessibleContext().setAccessibleName("Submit Button");
            button.getAccessibleContext().setAccessibleDescription("Click to submit the form");

            // Add a text field with accessible properties
            JTextField textField = new JTextField(20);
            textField.getAccessibleContext().setAccessibleName("Input Field");
            textField.getAccessibleContext().setAccessibleDescription("Enter your text here");

            panel.add(new JLabel("Enter Text:"));
            panel.add(textField);
            panel.add(button);

            frame.add(panel);
            frame.setVisible(true);
        });
    }
}

I launched both Windows CMD app and Inspect.exe as administrator, but I still not able to see the Submit button element.
What am I doing wrong?

(Is it possible to have a teams call?)

@bwomsm1
Copy link
Author

bwomsm1 commented Jan 28, 2025

I also called to jabswitch -enable before running both Inspect.exe and my app

@anunay1
Copy link

anunay1 commented Jan 28, 2025

Is it a java application?

@bwomsm1
Copy link
Author

bwomsm1 commented Jan 28, 2025

Is it a java application?

Yes, java app

@anunay1
Copy link

anunay1 commented Jan 28, 2025

Winappdriver will not work it's only for win32, wpf and uwp applications.

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

2 participants