how to close a tabbed window using testcomplete? - winforms

I am trying to access a tabbed window which is under Multiple Document interface window under which there are tabs which are generated dynamically.
I wanted to check whether the new tab is opened successfully or not, and after its been opened i need to close it too.I tried to get the number of tabs opened using the following piece of code:
mdiclient.ChildCount
Now need a way to close the opened Tab without using Click coordinates.

Try getting the tab object as a child of the mdiclient window and then call its Close method.

tried using The Close one .. but it always closed the 1st tab .. so i found a Workaround,
use :
mdiclient.Child(index).Dispose
Worked for me like a charm... got the count of the number of tabs opened using the
mdiclient.Controls.get_count

Related

How can I open a sidebar link in the same tab?

Is there a way to open a link in a WebExtension sidebar to the currently active tab? I don't want to automatically open the link in a new tab. I'm talking about regular links:
Example
Things I've tried:
Adding any target value to the a element does not seem to have the desired effect for any value.
Calling window.location.replace opens the link in the sidebar instead of the currently active tab.
Getting the current tab by using browser.tabs.query and setting tab.url for the sole result does nothing (even though I have added the tabs permission to manifest.json).
At this point, I'm kind of thinking this might not be possible. Is this the case?

How to open modal wpf window scoped to a tab item

I have a use case where we have an application with a tabcontrol with 2 or more tab items . I want to be able to open a modal Window (using Window.showDialogue()) so the user is blocked to do any thing else within the active tab item from where the modal window was opened . But should be able to click on other tab item and continue to do the work .
Currently Window.showDialogue() completely blocks all user interactions until the window is closed . Is it possible to change the scope of the blocking window to just the initiating tab item ?
As an alternative , I have a overlay design to show the popup content using the Panel.Zindex and then disable the underlying controls container . But I would prefer to do the simple way of window.showdialogue().
Any help would be appreciated.
As far as I know, here is no way to block only part of a Window when calling ShowDialog. The blocking is done at the Window level by the OS. You'll have to manually disable that tab.
Be aware that if you simply put another element on top of the tab to obscure it, the user may still be able to access the controls below by using the Tab key. You might need to set IsEnabled to false, or maybe IsHitTestVisible, depending on the how you want the application to behave.

WPF - Focus second window by clicking a button

I'm creating a WPF application and I have 3 Windows (MainWindow, Window2 and Window3). When I start the project Window2 loads right after my MainWindow is loaded. And when I click a Button, Window3 opens
Window3 w3 = new Window3(this, this.window2);
w3.ShowDialog();
but I'm not able to do things (click controls etc.) in Window2, I know that ShowDialog() method is disabling other open Windows but is there a possibility to access using those controls in Window2. How could I get access to Window2's functionalities when Window3 is open?
PS.(Sorry for asking a stupid question but I'm beginner in WPF)!
You can access System.Windows.Application static class's Windows collection to have list of all currently opened windows. Then you can iterate the collection and find your window by type or some other criteria. One way would be:
var window3 = Application.Current.Windows.OfType<Window3>().FirstOrDefault();
Edit:
In comments to the question you stated that you were opening window using w3.Show() method. That opens window in non modal way. While after editing the question w3.ShowDialog() opens the window in modal way.
You can learn more about modal windows at MSDN
A modal dialog box is displayed by a function when the function needs additional data from a user to continue. Because the function depends on the modal dialog box to gather data, the modal dialog box also prevents a user from activating other windows in the application while it remains open.
So to be able to switch focus between windows they should be non modal and opened using Show method instead of ShowDialog.

Powershell: How to open a file from a separate window

I'm using PowerShell for about a week now. I am able to open a specific URL and fill in my username and password automatically. I can also navigate to a certain page where multiple files can be found to download.
I use the following command to select a certain file to download:
$ie.navigate2('http://www.example.com/resource.aspx?ResourceID=GetDocStoreFile&EntryID=1234')
What happens next is that a second window will open, named "file download". There are three buttons: open, save and close.
I don't want to press the "open" button manually, but would like the script to do that for me and then goes back to the original window to select another file. Any suggestions?
If you use a download URL, I don't think you can interact directly with IE using the COM object, because there's no document. Once the dialog box opens, all of the object's properties become null. You can use the method I posted here: How to perform keystroke inside powershell? AppActivate will work to activate a dialog box by title.
The % represents the the ALT key, so if the underlined letter of the button you want to click is O, you'd invoke SendKeys like this:
$wshell.SendKeys('%O')

Popup windows that automatically close in Selenium Webdriver

My Selenium Webdriver test is something like:
Click button -> this opens popup window
Iterate through all window handles and switch to popup window
Fill out form on popup window and submit.
At this point, the popup window might automatically close if the input was valid or it will stay open if there is an error on the form.
My question is, if the window automatically closes and that was the window handle I had focus on, what happens exactly? Is there a way for me to detect that the window has closed?
Thanks
If the focused window closed, then the Web Driver instance had no focus on any window and it throw an exception if you are trying to find any element. It throws NoSuchElementException when you trying to find an element. You can check the window presence by counting the number of windows.
The windows handles keeps the record of pop of window even if it closes automatically. So you have to switch to the parent window. And then use the print statement for Windows.title to check which window is opened.

Resources