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

Alerts are not displayed in 'Inspector' and may not be interracted #129

Closed
dnovikau opened this issue Jan 12, 2016 · 2 comments
Closed

Alerts are not displayed in 'Inspector' and may not be interracted #129

dnovikau opened this issue Jan 12, 2016 · 2 comments

Comments

@dnovikau
Copy link

  1. In appropriate circumstances my AUT displays some alert over the main screen and waits the users interaction
  2. Using the 'Winium.Inspector' i was not able to find displayed alert in the tree and as a result was not able to perform appropriate action
    image
@NickAb
Copy link
Contributor

NickAb commented Jan 12, 2016

MessageDialog is not attached to current window popups, but ContentDialog is.
The easiest way to work with alerts at the moment is to replace MessageDialog with ContentDialog.

For example, in our test app I had

var noWifiDialog = new MessageDialog("Here's the content/string.", "Hello!")
{
Title = "No wifi connection",
Content = "Check connection and try again"
};
noWifiDialog.Commands.Add(new UICommand("Ok", this.CommandHandlers));
noWifiDialog.ShowAsync();

So I replaced it with:

var noWifiDialog = new ContentDialog()
{
Title = "No wifi connection",
Content = "Check connection and try again",
PrimaryButtonText = "Ok"
};
noWifiDialog.ShowAsync();

Now the ContentDialog is shown in Winium.Inspector. It's content is appended to the bottom of the tree. And now you can interact with it just like with the rest of interface.

This is how it can be done in python (which should be easy to translate to C#):

By.XNAME = 'xname'  # this is for example only, in real cases attach Automation Properties to buttons and use them to locate elements

dialog = driver.find_element_by_class_name('Windows.UI.Xaml.Controls.ContentDialog')
print(dialog.find_element(By.XNAME, 'Title').text)  # not that it is preferred to attach AutomationProperties and use AutomationId or Name instead of xname
print(dialog.find_element(By.XNAME, 'Content').text)

dialog.find_element(By.XNAME, 'Button1Host').click()

@dnovikau
Copy link
Author

Issue resolved by migrating to ContentDialog

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