How can I wait for a button to be visible? - testing

I need to click on a button that is only visible after validating the email, phone and name fields.
I don't want to use "WAIT".
I also used "VISIBILITYCHECK" (this.buttonOk = Selector('button',{ visibilityCheck: true }).withText('Ok');), but it didn't work.
Tela com os campos nome, email e telefone

You can use the Selector Timeout for this.

Related

How do I enable the radio button after I disable it?

I put my code like this, so when I select that radio button it will disable the same button in other form. But I realized if I select another radiobutton it will not enable, which means my code will only help me disable the radiobutton but not help me enable it back. But I have no idea how to.
Here's my code
If RadioButton1.Checked = True Then
Form1.TextBox1.Text = "Literary Studies and Creative Writing 10"
Form12.RadioButton1.Enabled = False
Form20.RadioButton1.Enabled = False
End If
The question you're asking is somewhat ambiguous, but just for the sake of helping I want to throw in some ideas.
You could make a "reset state" function inside your forms and that function can enable back all the radios or empty textbox, etc.
So whenever you want to enable back the controllers in a different form you can re enable them calling that function maybe on some event related to the form.
For example :
Function EnableRadios()
RadioButton1.Enabled = True
RadioButton2.Enabled = True
End Function
Also if you make your forms work as a template your function could work in any form, the more standard your form is the better approach you will have on the task.

How to automatically close the dialog box?

I have a WinForm application that have an automatic logout after some time without activity performed by the user, that application have some dialog box like
SearchCustomer.ShowDialog()
If the user left that dialog opened and the time expire the user is automatically logged out but that dialog box remains opened, so anybody can use that dialog even with the user logged out.
There's any way to close those dialog box from main Form?
Edit:
There's another Dialog box opened in a different way
AddCustomer.Show()
AddCustomer.BringToFront()
Edit 2 Solution based on jmcilhinney answer
For Each openForm In openForms
Dim H1 As Integer = openForm.GetHashCode()
Dim H2 As Integer = Me.GetHashCode()
If H1 <> H2 Then 'No igual
openForm.Close()
End If
Next
I haven't tested but I would think that you should be able to do something along these lines:
Dim openForms = My.Application.OpenForms.Cast(Of Form)().ToArray()
For Each openForm In openForms
openForm.Close()
Next
Here is an option.
Open your form with the ownership attribute.
AddCustomer.Show(Me)
'This open the form and gives the referring form ownership.
'It Also gives focus to the child form, keeping it on top of the referring form
When the referring form closes, so does the child form.

How to create a VB program that auto-fills credentials on other program

I wish to create a VB program which can auto fill in the credentials (Username and password) on another program.
This is the program I wish to fill the credentials in:
How do I do it?
I wanted to try SendKeys.
It seems that I need to use my mouse to click the field in order to fill it in.
I hope someone can help me.
Ps: Im using VB 2010
Following your SendKeys approach, just try to simulate a Tabulation key to navigate through the controls to focus on the desired edit-control then send the desired text simulating the rest of keys.
Example:
For count As Integer = 0 To X ' x = Many times as required to focus the username textbox.
SendKeys.Send("{TAB}")
Next count
SendKeys.Send("username")
SendKeys.Send("{TAB}")
SendKeys.Send("password")

Test if the user control is already in a form

I have a user control in my project and I want when I click on a button to add this user control to a form, but if the user control is already in the form I want to show it.
This the code I wrote so far:
Using GstAbonnement As New GestionAbonnement
GstAbonnement.Dock = DockStyle.Fill
Me.Controls.Add(GstAbonnement)
End Using
How can I test if the user control is already in the form or not ?
With your current code, that control will never be found in the form because the Using...End Using syntax with dispose of the control.
Try changing it to this:
Dim GstAbonnement As New GestionAbonnement
GstAbonnement.Name = "gestionAbonnement1"
GstAbonnement.Dock = DockStyle.Fill
Me.Controls.Add(GstAbonnement)
Notice I supplied a name for the control.
Now you can simply check the key if the control was in the collection or not:
If Me.Controls.ContainsKey("gestionAbonnement1") Then
Me.Controls("gestionAbonnement1").Visible = True
Me.Controls("gestionAbonnement1").BringToFront()
MessageBox.Show("Found!")
End If
You can use Form.Controls.Find to search for a specific control on a form. It also accepts a property to enable searching sub-controls (e.g. panels, groupboxes) which may contain the control.
You can use Form.Controls.Find as Su Sha said.
OR
You can loop through the Form.Controls to find the control with the specific name.
I'd prefer Form.Controls.Find function, its more safe and easier.

How to open forms ussing keyboard keys

I would like to be able to press shift+D+A+L to open another form (form2) ussing VB.net how do i do this?
Set the forms KeyPreview property to true, then add code to the forms KeyDown event. Y
Then use an if statement e.g
If e.KeyCode = Keys.F1 Then
Add each key you want as a condition and since you want to use shift add this to your if;
e.modifier = keys.shift
Then create a new instance of the second form and call the showdialog function.