How to refresh a certain tab?

Ask general questions here.
mrt
Posts: 257
Joined: Mon Mar 16, 2020 11:31 am

How to refresh a certain tab?

Post by mrt » Tue May 03, 2022 11:43 am

Dear all,

I open a website and do some tasks there, then I open a result page in a second tab, and there I have to wait until the result exists.

So my idea was to manually refresh the page every 30 seconds until the result is visible - but when I execute a refresh on the DOM object of the repository, it always refreshes the first tab.

How is it possible to refresh a certain tab, when there are multiple tabs open with the same base URL resp. the same DOM object?

thanks!

mrt
Posts: 257
Joined: Mon Mar 16, 2020 11:31 am

Re: How to refresh a certain tab?

Post by mrt » Tue May 03, 2022 11:59 am

I found a somehow solution by changing the path of the toplevel DOM repository item from:

Code: Select all

/dom[@domain='myDomain.com' and @state='complete']
to

Code: Select all

/dom[@domain='myDomain.com' and @state='complete' and @visible='True']
This way the refresh is executed on the visible tab only, which is the last one that was used.

It helps in my current use case, but I wonder if there is a better solution possible that maybe works for more than "the actual" tab?

mrt
Posts: 257
Joined: Mon Mar 16, 2020 11:31 am

Re: How to refresh a certain tab?

Post by mrt » Wed May 04, 2022 3:35 pm

Ok, my mistake, setting the

Code: Select all

and visible='True'
breaks several other stuff in my code, so that's no solution for my case.

Any ideas?

haydenf
Posts: 2
Joined: Tue Apr 26, 2022 3:16 pm

Re: How to refresh a certain tab?

Post by haydenf » Wed May 04, 2022 10:16 pm

A solution to a similar problem that I had was splitting other page in to a seperate App Folder in the repository. In your case, the path might look like

Code: Select all

/dom[@domain='myDomain.com' and @state='complete' and @caption~'Results']
Then, your refresh action would just be done to this repo item and the rest of your repo items would remain the same. You'll probably want to move the items on your results page under this app folder but I'm not sure it's strictly necessary.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to refresh a certain tab?

Post by odklizec » Thu May 05, 2022 12:40 pm

Hi,

My first suggestion would be to use ExecusteScript over a DOM element, as described here:
https://www.ranorex.info/viewtopic.php? ... 51&p=48848
However, because you want to perform refresh over an actually "selected" tab, this would require @visible='True' as you already tried and didn't like ;)

Another solution would be to send F5 shortcut to actually open tab. For example, let's say the tab you are looking for is YouTube, so the xpath you should use looks like this:
/form[@title~'YouTube']//tabpagelist[@accessiblerole='PageTabList']//tabpage[@AccessibleName='YouTube' and @selected='True']
Where @selected='True' assures that only the actually selected tab is returned. So then you can simply use Key Shortcut action to send F5 shortcut to the tab and it will refresh the page.

The above xpath should work both in FF and Chrome, but only if the AccessibleName is filled with proper tab name.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mrt
Posts: 257
Joined: Mon Mar 16, 2020 11:31 am

Re: How to refresh a certain tab?

Post by mrt » Fri May 06, 2022 9:06 am

Hi,

thanks for the hint to the title, identifying the correct tab by the page title resp. page url works for me.

I created an additional top-level repo item with variable in RXpath, so each tab is uniquely identifiable and i can then send a refresh to this tab, e.g.

this RXpath:

Code: Select all

MyRepoItem    Base: /dom[@domain='mydomain.com' and @pageurl<'someStuff/someOtherStuff/'+$myVar]
and this refresh call from UserCode:

Code: Select all

myRepo.Instance.MyRepoItem.Self.ExecuteScript("location.reload(true)");
Now everything is fine, thanks 8)