microsoft / WinAppDriver

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

AlertIsPresent expected condition is not functioning in WinAppDriver. #1051

Open ecchioni opened 4 years ago

ecchioni commented 4 years ago

ExpectedConditions.AlertIsPresent() is throwing System.InvalidOperationException: Command not recognized: GET: /session/CB68F3EE-CF0A-4DA3-9926-F88DBB3BFA35/alert_text 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.RemoteTargetLocator.Alert() at OpenQA.Selenium.Support.UI.ExpectedConditions.<AlertIsPresent>b__4c(IWebDriver driver) at OpenQA.Selenium.Support.UI.DefaultWait1.Until[TResult](Func`2 condition)

anunay1 commented 4 years ago

Have u checked the API document, is it even supported

ecchioni commented 4 years ago

If it is not supported than the product is next to useless.

PandaMagnus commented 4 years ago

If you're using C#, you can easily write a WebDriverWait function that executes an anonymous function to do this. Something like:

WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(15));
wait.IgnoreExceptionType(typeof(WebDriverException));
var alert = wait.Until(x => Driver.SwitchTo().Alert());

Might take a bit of tweaking to get to work right, but that should get you started at least. I believe java has the same functionality, but I'm not as familiar with the syntax to know how to demonstrate a good example.

Shakevg commented 4 years ago

@ecchioni, @PandaMagnus Looks like is not supported for now:

OpenQA.Selenium.WebDriverException: Command not recognized: GET: /session/CA65D585-13E8-4D31-9106-563D457FD945/alert_text
    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Appium.AppiumDriver`1.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteTargetLocator.Alert()