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

Window application starts from .bat file #1157

Closed
pzelazo opened this issue May 15, 2020 · 2 comments
Closed

Window application starts from .bat file #1157

pzelazo opened this issue May 15, 2020 · 2 comments

Comments

@pzelazo
Copy link

pzelazo commented May 15, 2020

Hi,
The application starts from .bat file, but the login screen is created in SWT_window0. I want to click in "User: " field and type login, then, "Password: " and type password but instead of it I receive and error. The error according to me appears because the session is assigned to cmd wind (created by .bat file) and I can't catch the splash screen.

Could you please tell me how can I get splash screen and assign to the new session? I should I make it in different way?

My code:

WindowsDriver application;
AppiumOptions desiredCapabilities = new AppiumOptions();
desiredCapabilities.AddAdditionalCapability("app", @"..\pathToApplication.bat");

        application = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), desiredCapabilities);

        Thread.Sleep(20000);

        // LeftClick on Edit "User: " at (90,2)
        Console.WriteLine("LeftClick on Edit \"User: \" at (90,2)");
        var winElem_LeftClickEditUser_90_2 = application.FindElementByName("User: ");
        if (winElem_LeftClickEditUser_90_2 != null)
        {
            winElem_LeftClickEditUser_90_2.Click();
        }
        else
        {
            Console.WriteLine($"Failed to find element using xpath: User");
            return;
        }

Error:
OpenQA.Selenium.WebDriverException
HResult=0x80131500
Message=An element could not be located on the page using the given search parameters.
Source=WebDriver
StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Appium.AppiumDriver1.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value) at OpenQA.Selenium.Appium.AppiumDriver1.FindElementByName(String name)
at ConsoleApp2.Program.Main(String[] args) in C:\Users\zelazop\source\repos\ConsoleApp2\Program.cs:line 53

@anunay1
Copy link

anunay1 commented May 15, 2020

A better option will be to start the batch file programatically and then create a desktop session as root and switch to the top level window.

@pzelazo
Copy link
Author

pzelazo commented May 18, 2020

@anunay1 for now, it works as you wrote :) Thank you.

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