"next" is appearing before download completes. i know it's a Async so will execute and release the control. Is there any way to wait for download before running the next command.
If System.Environment.Is64BitOperatingSystem = True Then
MsgBox("64 bit")
myurl = my64biturl
myfilename = "java-64.exe"
download = New WebClient
download.DownloadFileAsync(New Uri(myurl), "java.exe")
MsgBox("next")
Else
MsgBox("32-bit")
End If
Finally i got it working. Used the download_DownloadFileCompleted section to start another download or perform next action.
Related
Background:
I have a JAVA application on which we run our Test Complete scripts(We have recently moved from UFT to TestComplete, so TC is a bit new for us). The scripting language used is VBScript.
Issue:
In order to handle the slow application behavior, I have created a function which waits for an object to get loaded and become visible on the screen before any operation is performed on that object. But, at times, the function does not work. By this, I mean that even though the object is loaded and is visible on the screen, the function still keeps on waiting for the object i.e., uiObject.exists keeps on returning false due to which it keeps on waiting until the timeout value is reached. Has someone here faced this issue before?
Paramter values passed:
uiObject = Aliases.ParentObj.Login_Window
intMaxTimeOut = 120
Code
'============================================================================================================
'Function Name: fn_waitForObject
'Purpose: To wait for an object to exist and become visible on screen
'Creation Date: 04-06-2018
'Return type: true, if the object exists and is visible; false, if the object doesn't exist
'Parameters: uiObject - The object for which the script waits to get visible on screen
' intMaxTimeOut - Maximum timeout in seconds
'============================================================================================================
function fn_waitForObject(uiObject,intMaxTimeOut)
Dim intCounter : intCounter = 0
Do While (intCounter < intMaxTimeOut)
If uiObject.exists then
Exit Do
Else
intCounter = intCounter + 1
delay 1000
End If
Loop
'If the object exists, make sure that it is visible on screen
If uiObject.exists then
Do While (intCounter < intMaxTimeOut)
If uiObject.visibleonscreen then
Log.Message "The object """&uiObject.toString&""" exists and is visible on screen"
Exit Do
Else
intCounter = intCounter + 1
delay 1000
End If
Loop
End If
fn_waitForObject = uiObject.visibleonscreen
End Function
Object Spy
Maybe the information on this link can help you!
whats is the difference between UIObject and UIObject2 other than UIAutomator 2.0 version name?
What is the actual error saying in TC?
Have you seen this link? https://support.smartbear.com/testcomplete/docs/app-objects/common-tasks/waiting-process-or-window-activation.html
I would also suggest trying to use the record keyword test, then convert it to script
For now you could increase your max timeout value, but your while loop will still have a hard upper limit. I recommend using one of the methods listed in the article above, as they will make TestComplete wait until your process/objects have fully loaded, no matter how much time has passed. That way, you won't run into your current problem anymore.
It is the Name Mapping creating a 2nd version of the same object.
Go into the Name Mapping and edit the properties to only use static properties, so new versions of the same UIObject are not being created.
With some, limited, success, I'm able to automate VS to execute some arbitrary PS in the Package Manager Console. The following is roughly the code I have running so far:
MessageFilter.Register()
try
{
var type = Type.GetTypeFromProgID("VisualStudio.DTE.14.0");
var comObj = Activator.CreateInstance(type);
var dte = (DTE2) comObj;
try
{
dte.MainWindow.Activate();
Thread.Sleep(10000); // WAIT 1
dte.Solution.Open("path/to/sln");
dte.ExecuteCommand("View.PackageManagerConsole");
Thread.Sleep(10000); // WAIT 2
dte.ExecuteCommand("View.PackageManagerConsole", "Start-Sleep -Seconds 10")
Thread.Sleep(10000); // WAIT 3
dte.Solution.Close();
}
finally
{
dte.Quit()
}
}
finally
{
MessageFilter.Revoke();
}
Is there some way to remove the waits and subscribe to some events when some operation has completed? I'm especially curious about WAIT 2 and WAIT 3 above, which would occur after PMC commands (first to open it, and then to invoke the PS command).
Unrelatedly, is there a way of doing all this without having to make the VS window active? I suspect not, because I get an exception without dte.MainWindow.Activate().
My end goal is to be able to run Update-Package with a specific version for a given package and solution, although running any arbitrary PMC command would have other advantages as well. Unfortunately nuget.exe doesn't give the option of passing in a version AFAIK. For a large solution, the update can take a while, so there's no good way of knowing when it has completed.
One idea is that you could still use the Sleep method but with short time, for example, add a "for" loop for 10 times, just wart for 1000 ms every time, and use a method to check that whether one process like the VS windows was running using C# code(sample), at least, it will optimize the performance.
For the Nuget package update, the similar steps as above suggestion, you could get the package version number using C# code, just compare the version number.
I write a application use notifycation on winphone 8. My application require send URI continuous to server every 30 seconds. My problem, i used reminder of winphone, but it can't use webbrowser call request in reminder.
My code:
public MainPage()
{
InitializeComponent();
var reminder = new Reminder("MyReminder")
{
Content = "Sending uri to server...",
BeginTime = DateTime.Now.AddSeconds(30),
webBrowser1.Navigate(new Uri("http://nhomxe.vn/device_register?uri="http://...", UriKind.Absolute));
};
ScheduledActionService.Add(reminder);
}
I think you're misunderstanding what the Reminder class is for and how to use it.
The Reminder class will display a prompt to the user with a piece of shell UI and allow them to tap on it to open your app. (Similar to an Alarm which also displays UI and allows you to customize the sound that is played but doesn't support a direct link to the app.)
The code you have written doesn't compile because you are writing the code to execute inside the object initializer which won't work. You also appear to have a string concatenation issue but this may just be a spurious quote(").
If you just want to make a request to a URL endpoint you also don't need to load it in a browser.
Assuming that you're wanting to send a message to your server every 30 seconds while the app is running then you could just do this with a Timer.
Like this:
var timer = new Timer(
state => new WebClient().DownloadStringAsync(new Uri("http://blah.blah/")),
null,
TimeSpan.FromSeconds(30),
TimeSpan.FromSeconds(30));
Obviously add error handling, etc.
It is not possible to have your code run every 30 seconds when your app is not running. If you want to do something when your app is not in the foreground then you need to look at using Background Agents.
You can use periodic task if you want to fetch information every 30 mins.
i have a windows forms application to backup certain files.
Normally you hit the button "Start Backup" and the programm
will do whatever is selected as an option.
Now i have implemented via Task Sceduler DLL the possibility
to do the backup on a desired day and time via a datetimepicker
object.
So far i only found out how to register the the programm.exe
in Windows and it also starts up on the chosen time.
My question now is how would it be possible to be able to execute
the "Start Backup" button via automation or a script? All other needed
parameters for the programm are stored in Settings.Default values.
Code from the Task Scheduler, maybe there is a shorter way to solve
the problem?
private void futureBackup_Click(object sender, EventArgs e)
{
dateTimePicker1.Format = DateTimePickerFormat.Time;
TaskService ts = new TaskService();
TaskDefinition td = ts.NewTask();
Trigger t = new TimeTrigger();
t.StartBoundary = System.DateTime.Now.Date
+this.dateTimePicker1.Value.TimeOfDay;
td.Triggers.Add(t);
string path1 = Desktop + #"\Desktop\Release\Backup.exe";
td.Actions.Add(new ExecAction(path1, null, null));
ts.RootFolder.RegisterTaskDefinition("XBackupX", td);
ts.BeginInit();
}
I found the UI Automation in Visual Studio but i am not exactly sure if that's what can fix the "problem"!?!
Thank you in advance
for now the easiest way i came up with is to have
2 programm exe files... 2nd one is called backup_s.exe
which then is added to the task scheduler in windows.
only difference between the 2 codes is _s loads the last
options automatically from an xml file then executes the
start backup by trigger event and closes itself after 1
minute.
So I'm debugging some websites (one from trunk, one from branch) running locally, in separate apppools. I have trunk and branch solutions open in two VS instances. I'd like to debug trunk in one, and branch in the other. I'd like to know if there's a way to know which application pool each w3wp.exe is serving, to know which one is which when attaching the debugger.
Update: the point of this is to write a macro within VS to then let me have a button (per app-pool that is interesting) which will be clickable to attach the debugger to. So solutions should preferably not involve other programs.
Update2: this is on Windows 7 against IIS7.
Below is my core macro. Write a few one-line subs calling it, like AttachToW3wp("DefaultAppPool") naming each app pool you’re interested in, and make buttons and hotkeys for them.
Private Sub AttachToW3wp(ByVal appPoolName As String)
Const processName As String = "w3wp.exe"
Dim userName As String = String.Format("IIS APPPOOL\{0}", appPoolName)
Try
Dim debugger As EnvDTE90.Debugger3 = CType(DTE.Debugger, EnvDTE90.Debugger3)
'debugger.DetachAll()
Dim transport As EnvDTE80.Transport = debugger.Transports.Item("Default")
Dim qualifier As String = Environment.MachineName '= My.Computer.Name
Dim engines(3) As EnvDTE80.Engine
engines(0) = transport.Engines.Item("Managed")
engines(1) = transport.Engines.Item("Script")
engines(2) = transport.Engines.Item("T-SQL")
Dim successMessage As String = String.Empty
For Each process As EnvDTE80.Process2 In debugger.GetProcesses(transport, qualifier)
With process
Dim fi As New System.IO.FileInfo(.Name)
If fi.Name = processName AndAlso (String.Compare(.UserName, 0, userName, 0, Len(userName), True) = 0) Then
If .IsBeingDebugged Then Throw New Exception(String.Format("{0} {1} is already attached to a debugger.", processName, userName))
process.Attach2(engines)
successMessage = String.Format("Attached to {0} for {1} ({2})", processName, userName, .ProcessID)
Exit For
End If
End With
Next
If successMessage = String.Empty Then
Throw New Exception(String.Format("{0} {1} not found.", processName, userName))
Else
Trace.WriteLine(successMessage)
End If
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
Another option would be the WADA - W3WP Advanced Attacher available in the Visual Studio Gallery. I found it by searching in the Online Gallery of Extension Manager for "attach worker".
Look at the answers to this question. There are built in scripts you can run from a command window to do this.
If you can execute a request on each branch, you could use something like Process Explorer or Task Manager to see which ID is which possibly as one may be taking up CPU cycles that is currently processing a request assuming you can get such separation.
You can use task manager to view the user name under which the process is running (which in general is the same as the application pool name) and the process ID, but you have to turn on these columns in task manager, and also the process name has to be the same as the application pool (which is the default as far as I know).
Also note that all methods listed on this page might only display the processes that are currently running, which means that if your particular process has shut down due to idle time you have first to use the site in order to bring the process up in the list, and in your case it means you should first access all sites to make sure that the process associated with them is runing.