microsoft / WinAppDriver

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

Currently selected window has been closed #1478

Closed pradeepjgowda closed 3 years ago

pradeepjgowda commented 3 years ago

Recently started to Automate Desktop applications using Appium WInappdriver. Using Appium driver successfully able to launch application. Application first display slash screen and then the Signin form. Encounterd the issue Currently selected window has been closed

image

Tried with the code below as well, its not working Thread.Sleep(TimeSpan.FromSeconds(5)); LogonSession.SwitchTo().Window(LogonSession.WindowHandles[0]); LogonSession.ActivateApp("AppPath");

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.Remote.RemoteWebDriver.FindElementByXPath(String xpath) at OpenQA.Selenium.Appium.AppiumDriver1.FindElementByXPath(String xpath) at RnL.Tests.AppControlBase.Setup(TestContext context)

Can any one help on this? Thanks for the help!!

anunay1 commented 3 years ago

You need to create a root session and then switch to that window read the wiki

pradeepjgowda commented 3 years ago

Thanks it works

pradeepjgowda commented 3 years ago

Thanks it works, is there a way to set priority to the unit test cases, currently I set using Priority attribute but the execution of test case sequence are not based on priority number

anunay1 commented 3 years ago

The priority attribute is useless in unitests, better to use nunit.

sshweta2727 commented 1 year ago

@pradeepjgowda @anunay1 -I am having similar issues with my desktop application.I have written the below code:

private static WindowsDriver dri;

public static void main(String[] args) throws MalformedURLException, InterruptedException
{
    DesiredCapabilities cap=new DesiredCapabilities();
    //cap.setCapability("app", "C:\\Windows\\System32\\notepad.exe");
    cap.setCapability("app","C:\\Program Files\\QSR\\NVivo\\NVivo.exe");
    cap.setCapability("platformName", "Windows");
    cap.setCapability("platformVersion", "10");
    cap.setCapability("deviceName", "WindowsPC");
    dri = new WindowsDriver(new URL("http://127.0.0.1:4723"), cap);

    Thread.sleep(20000);
    WebDriverWait wait=new WebDriverWait(dri,30);
    Thread.sleep(20000);

     dri.findElementByXPath("//Button[@Name='FILE'][@AutomationId='fileButton']").click();

My application does launch but then I get this error as below

Nov 10, 2022 11:53:15 AM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0 INFO: Detected dialect: OSS Exception in thread "main" org.openqa.selenium.NoSuchWindowException: Currently selected window has been closed (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'QSR-L-01335', ip: '192.168.80.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '19' Driver info: io.appium.java_client.windows.WindowsDriver Capabilities {app: C:\Program Files\QSR\NVivo..., javascriptEnabled: true, platform: WINDOWS, platformName: Windows, platformVersion: 10} Session ID: 45350DDD-2430-4579-9062-26A32D40BFF1 *** Element info: {Using=xpath, value=//Button[@Name='FILE'][@AutomationId='fileButton']} at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166) at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40) at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80) at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at io.appium.java_client.windows.WindowsDriver.execute(WindowsDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323) at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:61) at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1) at io.appium.java_client.windows.WindowsDriver.findElement(WindowsDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428) at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:151) at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1) at io.appium.java_client.windows.WindowsDriver.findElementByXPath(WindowsDriver.java:1)

I read something like: You need to create a root session and then switch to that window read the wiki Can you please let me know how to create a root session

AshokMarrapu commented 1 year ago

Hi the same above mentioned issue ("You need to create a root session and then switch to that window read the wiki Can you please let me know how to create a root session") is coming up for me too. Can somebody help please!

anunay1 commented 1 year ago

Have you read the wiki

AshokMarrapu commented 1 year ago

Hi thanks alot for the reply ... I didn't find any wiki for it. Can you please send me the link of you have. Thank you

On Wed, 14 Jun 2023, 08:40 ANUNAYA THAKUR, @.***> wrote:

Have you read the wiki

— Reply to this email directly, view it on GitHub https://github.com/microsoft/WinAppDriver/issues/1478#issuecomment-1590383862, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAGIFERL623SF6D32QOVLSLXLETRDANCNFSM4ZVASP7Q . You are receiving this because you commented.Message ID: @.***>

anunay1 commented 1 year ago

Hi thanks alot for the reply ... I didn't find any wiki for it. Can you please send me the link of you have. Thank you

On Wed, 14 Jun 2023, 08:40 ANUNAYA THAKUR, @.***> wrote:

Have you read the wiki

— Reply to this email directly, view it on GitHub https://github.com/microsoft/WinAppDriver/issues/1478#issuecomment-1590383862, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAGIFERL623SF6D32QOVLSLXLETRDANCNFSM4ZVASP7Q . You are receiving this because you commented.Message ID: @.***>

https://github.com/microsoft/WinAppDriver/blob/master/Docs/FAQ.md

AshokMarrapu commented 1 year ago

Heya thanks for the link. Yep I did read this and it says: You need to create a root session and then switch to that window. I'm not sure on how to create a root session.

My exact issue is:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 0 milliseconds

On Wed, Jun 14, 2023 at 8:55 AM ANUNAYA THAKUR @.***> wrote:

Hi thanks alot for the reply ... I didn't find any wiki for it. Can you please send me the link of you have. Thank you

On Wed, 14 Jun 2023, 08:40 ANUNAYA THAKUR, @.***> wrote:

Have you read the wiki

— Reply to this email directly, view it on GitHub

1478 (comment)

https://github.com/microsoft/WinAppDriver/issues/1478#issuecomment-1590383862 , or unsubscribe

https://github.com/notifications/unsubscribe-auth/BAGIFERL623SF6D32QOVLSLXLETRDANCNFSM4ZVASP7Q . You are receiving this because you commented.Message ID: @.***>

https://github.com/microsoft/WinAppDriver/blob/master/Docs/FAQ.md

— Reply to this email directly, view it on GitHub https://github.com/microsoft/WinAppDriver/issues/1478#issuecomment-1590398634, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAGIFEVR375W34MPXTZBFLTXLEVLDANCNFSM4ZVASP7Q . You are receiving this because you commented.Message ID: @.***>

anunay1 commented 1 year ago

I don't know which language binding are you using check with my username in the closed issue, i have given the code.

AshokMarrapu commented 1 year ago

Hi. It's working now. Thank you for helping out Anunaya

Regards, Ashok

On Wed, Jun 14, 2023 at 10:15 AM ANUNAYA THAKUR @.***> wrote:

I don't know which language binding are you using check with my username in the closed issue, i have given the code.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/WinAppDriver/issues/1478#issuecomment-1590460201, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAGIFERD5EEZZVFU5Z4QOZTXLE6WLANCNFSM4ZVASP7Q . You are receiving this because you commented.Message ID: @.***>

AshokMarrapu commented 1 year ago

Hi,

Hope you are doing well!

Can you please suggest to me the supported TestNG version for Windows application automation using maven, winapp driver and java ?

Regards, Ashok M

On Thu, Jun 15, 2023 at 2:35 PM ashok m @.***> wrote:

Hi. It's working now. Thank you for helping out Anunaya

Regards, Ashok

On Wed, Jun 14, 2023 at 10:15 AM ANUNAYA THAKUR @.***> wrote:

I don't know which language binding are you using check with my username in the closed issue, i have given the code.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/WinAppDriver/issues/1478#issuecomment-1590460201, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAGIFERD5EEZZVFU5Z4QOZTXLE6WLANCNFSM4ZVASP7Q . You are receiving this because you commented.Message ID: @.***>

anunay1 commented 1 year ago

Any Test NG should work, what is the issue that you are facing.

AshokMarrapu commented 1 year ago

Hi,

I think there is some issue with configuration. I'll check it out and let you know if I'm stuck on that.

I'm working on Desktop outlook automation currently. My task is to insert a document in the mail and send it. I'm able to click on insert and then click on "browse PC" in order to attach the required document but I'm stuck after that since a dialog box of the local folder appears and then I'm not able to insert the attachment to the mail. Can you please guide me over here if possible? Thanks in advance

Regards, Ashok M

On Thu, Jun 22, 2023 at 2:27 PM ANUNAYA THAKUR @.***> wrote:

Any Test NG should work, what is the issue that you are facing.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/WinAppDriver/issues/1478#issuecomment-1602269119, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAGIFEXGSFDQML2OJHXCZ23XMQCIRANCNFSM4ZVASP7Q . You are receiving this because you commented.Message ID: @.***>

anunay1 commented 1 year ago

In the filename field:

image

use send keys to send the filename with path and Keys.Enter.

AshokMarrapu commented 1 year ago

Ok, I will do that. Thank you so much

On Thu, Jun 22, 2023 at 8:47 PM ANUNAYA THAKUR @.***> wrote:

In the filename field: [image: image] https://user-images.githubusercontent.com/7989610/247976563-d5478653-2b64-4ed1-82b6-0dc25176d108.png

use send keys to send the filename with path and Keys.Enter.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/WinAppDriver/issues/1478#issuecomment-1602824343, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAGIFEU6NVKIPHA4477FBF3XMROXLANCNFSM4ZVASP7Q . You are receiving this because you commented.Message ID: @.***>