White/TestStack UI Automation - clicks app button opens a browser, how do I check the url? - windows

I am currently using White/TestStack to test a windows app.
There are scenarios that requires user to click on links to open pages on browser. How do I check the hyperlink is working?

Old question but in case somebody else looking for an answer:
If you check in the White GitHub repository and you browse the UITests and the control tests, you will find the Hyperlink control test. In the sourcecode, you will find several tests according the type of framework used.
The simplest one:
var hyperlink = MainWindow.Get<Hyperlink>("LinkLabel");
hyperlink.Click(10, 10);
Assert.That(hyperlink.HelpText, Is.EqualTo("Hyperlink Clicked"));
The test is based on the used of code-behind for the MainWindow:
private void Hyperlink_OnClick(object sender, RoutedEventArgs e)
{
AutomationProperties.SetHelpText(LinkLabel, "Hyperlink Clicked");
}
XAML code of the hyperlink in the MainWindow
<TextBlock x:Name="LinkLabelContainer">
<Hyperlink x:Name="LinkLabel" Click="Hyperlink_OnClick">Link Text</Hyperlink>
</TextBlock>
So you can used the same method.
TL;DR
You can link the Click() event of your hyperlinks to a method in code behind which update the automation property HelpText of the hyperlink with a specific value for the clicked event.
So in your tests, you will just have to perform the click and then check the automation property value.

Related

how to set focus at specific position in Entry + xamarin.forms

my entry box has some text already.so can I set cursor focus at start of text?
how? I coudnt find any option for that.if anybody have idea.please suggest.
As you said
In mobile app there wont be focus in load of page.as there will not
keyboard open first.. once user clicks on text than keybopard will get
open.so wherever he click focus will be there?
In mobile app On load focus depend on the requirement. Check out most luxurious android app linkedIn login page, have focus in Username Entry without opening keypad. If you want to avoid using custom renderers in XF than you have to do bit compromise with functionality.
Your second point true- Wherever user clicks focus would be there.
Try doing like this, First update Xamarin.Forms version to 3.1.0.697729 from nuget packages & target framework change to Oreo 8.1.
XAML file
<StackLayout>
<Entry x:Name="txtDummy" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" />
</StackLayout>
your .cs file
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
protected override void OnAppearing()
{
txtDummy.Text = "I am focus";
txtDummy.Focus();
base.OnAppearing();
}
}
Look at output screenshot

Xamarin Forms open a view without Navigation

Xamarin Forms navigation examples I see leverage a NavigationPage...
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new HyperTrack2.Login());
}
and then when an event occurs to move to the next page...
async void OnLogin(object sender, EventArgs e)
{
await Navigation.PushAsync(new MapPage());
}
How can one show a view without using the NavigationPage?
Depends on what you consider a view to be.
The process you outlined in your question is the prefered way to navigate using Xamarin pages. Xamarin pages contain one or more controls, or views. Usually some layout views at the root and then they branch out as needed.
The built in navigation mechanism actually utilises the optimal native techniques for navigating inside your application and will allow you to use standard gestures and buttons for navigations, display standard toolbars and title views, etc.
I fully recommend that unless you have very specific needs, you keep using the built in navigation mechanism.
Otherwise, your other option for moving through xamarin.forms pages is by just settting the MainPage property of your Application class (called App by default)
You can either access it through Application.Current.MainPage = new MyPage(); or if writing code within the app class, directly by calling MainPage = new MyPage();
Lastly, you specifically mention showing a view and not a page. If you are talking about a single control within a page, you can either bind it's IsVisible property to some value in your ViewModel, or you can give it an x:Name="myControl" (if using XAML) or store a reference to it (if creating UI in code behind) and then do myControl.IsVisible = true/false somewhere in your code behind. This toggles the visibility of a single control, which will then become a part of your page hiearchy.
If you instead wish to display the view as a "popup" over the existing page, without it actually becoming a part of the page, there are some built in simple UI elements you can use, such as action sheet and display alert. These provide simple popup windows that offer a couple of actions or display a message.
For more complex UI, look into Nuget plugin packages, or if you prefer, you can write your own by implementing the functionality on all the target platforms you require.
I suggest looking into Acr User dialogs as it's a wonderful plugin that has served me quite well. It has a much broader set of UI elements you can use, but it still won't let you define any element that you want and display it in a popup, to do that, search for popup plugins for Xamarin.Forms. There are quite a few, but none work perfectly imho.

How to make a button on a application open a register page in Visual Studio

I'm making an application group chat in Visual Studio learn a bit more, all is good so far, so I've made my design and coded most of what I need, I have added a Button and called it Register now what I want is when people click it it will open another page or some type of menu where people can type there information in to register, I thought somthing like this or is this so wrong.
private void RegisterButton_Click(object sender, RoutedEventArgs e)
{
//what gose here
}
You can use Response.Redirect inside the button click to do this.
Refer to these articles:-
https://msdn.microsoft.com/en-us/library/a8wa7sdt(v=vs.110).aspx
https://support.microsoft.com/en-sg/kb/307903

Windows Form -- behavior of buttons?

First time I've used the windows form so I'm not very familiar with the interface. But how do I set behaviors when I add buttons? For example, if I want to click "Button 1" and have it open up a new window to enter information in different fields, how is this done?
Thank you.
edit: Sorry, I forgot to include the language. It's in C#, and I'm using MS Visual Studios. I've never really programed in C#.
Another question that just popped up: could I do this Windows Form in other languages such as C++?
Yes the comment above is key but, if your are using the UI designer on a windows form then under the properties tab on the side of visueal studios, you can view 'events'. from here double click the event you want, probably 'onclick'. This will create a method stub with the event handler automatically set up.
Look something like:
public void Button1_OnClick(Object sender, EventArgs e){
// open the other window for input
Form whateverForm = new Form();
whateverForm.show();
}
Hope this helps. Sorry im not sure about any c++
[Edit]
tutorial not great but take a look:
http://www.ehow.com/how_7241167_tutorial-microsoft-visual-studio.html

Can't Find Specific Listbox for Windows Phone

I am right now looking for a way for a user to open a listbox, choose an option, and the program continues to run, considering the desired option. My best option was to use a listbox I found in the Settings section of the phone.
I don't have a way of explaining this control completely, so I'll use an example. If you go into the Regions & Language section of the phone and then hit Region, you will notice a list pops open. The same listbox is opened when choosing a ringtone. This is exactly what I need for my application. The only problem is, I don't know what it is called. Help!
I included two images
That control is not called a ListBox, Windows Phone calls it the ListPicker. Here's an article explaining how to use it.
The control is included in the Silverlight Toolkit for Windows Phone.
Note that the article is old and a few of the properties for the control have been renamed / made read-only in the latest release of the toolkit.
What you need is the ListPicker from the Windows Phone Toolkit. You'll need to handle changing any settings yourself. This can be done through binding to a property that gets changed or via code that you write.
<toolkit:ListPicker Header="Language" SelectedItem="{Binding SelectedLanguage, Mode=TwoWay}"
FullModeHeader="LANGUAGES" ExpansionMode="FullScreenOnly"
SelectionChanged="ListPicker_SelectionChanged">
<sys:String>English</sys:String>
<sys:String>Spanish</sys:String>
<sys:String>French</sys:String>
</toolkit:ListPicker>
If you need to handle changes:
private void ListPicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// handle any changes that are needed
}

Resources