Click on the selected item of a tabstrip control in WinForms.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Click on the selected item of a tabstrip control in WinForms.
I am trying to automate a winforms application and when I use the object spy, it says its a tab strip control name is tabstrip1. How do I click/select the different tabs based on the name?
I try something like this but it doesn't work
//Aliases.EchoClientUtility.EchoClientApplicationForm.splitContainerMain.SplitterPanel.splitContainerUpper.SplitterPanel2.tabControl.tabStrip1.Click(178, 14); I don't want 178,14, I want to click based on the name.
//Aliases.EchoClientUtility.EchoClientApplicationForm.splitContainerMain.SplitterPanel.splitContainerUpper.SplitterPanel2.tabControl.WinFormsObject("tabControlPanelSurvey")
Aliases.EchoClientUtility.EchoClientApplicationForm.splitContainerMain.SplitterPanel.splitContainerUpper.SplitterPanel2.tabControl.tabStrip1.Click("tabControlPanelSurvey");
- Labels:
-
Desktop Testing
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looking at your alias names, following the tree strucure,
EchoClientApplicationForm
splitContainerMain
SplitterPanel
splitContainerUpper
SplitterPanel2
tabControl
tabStrip1
tabControlPanelSurvey
Can you confirm the highlighted sections are correct?
tabStrip1 doesn't seem to have a child object named tabControlPanelSurvey.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi its correct until tabStrip1. "tabControlPanelSurvey" is the name of one of the tabs that I want to click on the tabStrip1.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tabStrip1 doesn't have any child objects called tabControlPanelSurvey.
However, tabControl does have a child object called tabeControlPanelSurvey as well as tabStrip1, tabControlPanelFluideReplacem..etc.
If you were to do e.g. tabControl.tabStrip1.Click() or tabControl.Click("tabStrip1) then it may work.
Record a keyword test, then convert it to script. You will see how TC has recognised the objects.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I recorded a keyword test and tried all the options. When I say "Aliases.EchoClientUtility.EchoClientApplicationForm.splitContainerMain.SplitterPanel.splitContainerUpper.SplitterPanel2.tabControl.tabControlPanelSurvey.Click();"
"Aliases.EchoClientUtility.EchoClientApplicationForm.splitContainerMain.SplitterPanel.splitContainerUpper.SplitterPanel2.tabControl.Click("tabControlPanelSurvey");
It says the object tabControlPanelSurvey does not exist.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you able to use WinFormsObject Method to obtain the object, then perform a click?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes it shows the Name is WindFormsObject("tabstrip1")
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you tried the examples provided by TC, in my previous post?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks I tried something like this but nothing works.. It says "Unable to find the object ClickItem("tabControlPanelSurvey", 2)"
Sys.Process("EchoClientUtility").WinFormsObject("EchoClientApplicationForm").WinFormsObject("splitContainerMain").WinFormsObject("SplitterPanel", "", 1).WinFormsObject("splitContainerUpper").WinFormsObject("SplitterPanel", "", 1).WinFormsObject("tabControl").ClickItem("tabControlPanelSurvey",2);
I am having to use not a good approach (like the default script it generates after keyword test),
Aliases.EchoClientUtility.EchoClientApplicationForm.splitContainerMain.SplitterPanel.splitContainerUpper.SplitterPanel2.tabControl.tabStrip1.Click(85, 18);
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you try this please,
var tabControl = Sys.Process("EchoClientUtility").WinFormsObject("EchoClientApplicationForm").WinFormsObject("splitContainerMain").WinFormsObject("SplitterPanel", "", 1).WinFormsObject("splitContainerUpper").WinFormsObject("SplitterPanel", "", 1).WinFormsObject("tabControl")
Sys.HighlightObject(tabControl); // Is the tab control highlighted?
var tabControlPanelSurvey = tabControl.WinFormsObject("tabControlPanelSurvey");
Sys.HighlightObject(tabControlPanelSurvey); // Is the tab control survey highlighted?
tabControlPanelSurvey.Click();
Are the controls highlighted correctly?
Can you also, click on each of the tabs, then run the above code again. Because "tabControlPanelSurvey" is greyed out, the page could be dynamically created when it's clicked on.
