I am working on creating automated test cases for a WPF application using CodedUI. This application contains multiple modules like M1, M2, M3 etc. and I can open these modules from the menu item links. Now, if I click on M1 link 3 times, it opens the M1 screen in 3 different tabs like M1.1, M1.2, M1.3 (which is a requirement) and the issue starts from here.
If there is a button like "Create new record" on M1 screen, then CodedUI fails to click on this button if more than 1 tab of same screen exists i.e. it is there on M1.1, M1.2 and M1.3. As per my understanding CodedUI is looking for that button in M1.1 and if the focus is on M1.3 then it fails.
Possible solution which I can think of are:
Close all tabs (except one) of same screen i.e. Close M1.2 and M1.3 and then start execution of further steps on M1.1
Set my focus to the first tab e.g. Find M1.1 and set focus to it, and then execute further steps.
But these are kind of adding extra/unwanted steps to my test cases.
Is that possible that CodedUI clicks on the first visible button which is there on the tab being displayed, instead of trying to click on the very first button which might be there on a tab that is currently not in focus.