First posting so please be gentle with this newbie (I’m not even sure this is the right forum for this question).
I need to iterate through all the open tabs in Chrome to see if they are showing pages from a certain domain. When I identify these tabs I need to trigger a logging out process and then close the tab.
The trouble is the site is so badly designed, I cant just log out in one tab and expect to have all tabs log out at the same time. Sometimes logging out in one tab works for all, but not always. This is a problem for humans sat as keyboards as well
So how do I iterate through the tabs identifying the ones I want? Once I can do that I can attempt to log out in every tab. I can find ones to work with IE but they all say it wont work with Chrome because of a bug.
Any help or pointers would be very welcome (and apologies if my explanation is not very clear)
i suggest to use a send hotkey inside a loop, the keyword will be Ctrl + tab, this keys give us to move around the tabs, and inside you can use an element exist activity, to recognize the parameters you are telling.
I could certainly use that as a basis for what I need. I would have to be careful as I’m closing some tabs as I go. For instance, if I close tab “A”, chrome will presumably shift focus to tab “B”. So it I send another Ctrl + tab I will end up at tab “C” having skipped tab “B” - hopefully that makes sense)
Is there a good method to ensure I have used the hotkeys the right amount of times, as the number of tabs will be unknown? For example is it possible to get a count of tabs before I start iterating through the tabs - that way I can simply use a counter to ensure I have tabbed through the right amount of tabs
You need to create a sequence starting with a Try Catch and inside an Attach Window and inside log out and Close Tab, after this is working, you will need to make the attach window dynamic enough so it can find every last window opened…
After a lot of experimenting I found a way to find the number of tabs currently open in Chrome. Its a bit of an “around the houses” approach but it seems to work. This is the process;
In chrome open the page chrome://inspect/#pages in a new tab - This will give you a page listing all the open tabs in Chrome, including the chrome://inspect/#pages page its self.
Grab the text from the page and put it in to a string variable. I used the “Get Full Text” function for this.
Count the number of times the phrase “inspect pause” appears in the text (chrome puts this phrase after each page it lists) and deduct 1 as the page count includes the chrome://inspect/#pages page its self
Close the chrome://inspect/#pages page.
You can use sendkeys Ctrl & 1 to move to the first tab and the use the sendkeys Ctrl & Tab to iterate through the tabs.
I know its not best solution but it works for me - if anyone has any ideas on how to improve it they would be very welcome. I did try to extract the page’s HTML but for some reason I couldnt get it to work