How to detect if the front Safari window changes when the url and title do not change

Specific to a site where the url and title do not change, but the content does change, how can I tell if the page (content) changes after pressing a button?

A little more detail in case I am thinking about the problem in the wrong way: I want a macro to click an image, wait for the content to change, then look for another image.


If it changes enough, could you use an "Until - Found Image - Is not found" ?


1 Like

My ideas are not always 100% reliable, but they sometimes work when no other solution is found. I think this should work most of the time, but it may depend on the contents of your screen.


Is there a button (link) that appears when you want the pause to end? If so, you may be able to detect it using Javascript.

I have to run for now, but I wanted to post what I thought was a good idea until I discovered there's a hidden state that changes in the html every time. I will check the replies and post back later. Thanks all.

There's nothing wrong with your code, but it could be shortened using an UNTIL action which contains your Execute AppleScript action and then loops "until" your condition occurs.

1 Like

Thanks again for the replies. Not having much luck. I'm responding to the suggestions, but please feel free to drop out of the conversation :rofl:

  • @griffman I tried to capture the screen or an area of the screen to a named clipboard, and then use an If action to see if the screen contains that named clipboard, but it never does.

  • @Airy I can't get this OCR method to work on any screen. The macro always ends as if OCR never matches.

  • @noisneil the button is the same on every screen, so I'm not sure how that could work. It's an image in a table (antiquated site). Here is what the html looks like:
    <input type="image" name="ctl00$SlidePlaceHolder$Next" id="ctl00_SlidePlaceHolder_Next" class="SlideNext" src="../../images/Next.jpg" onclick=" this.disabled = true; __doPostBack('ctl00$SlidePlaceHolder$Next','');return false;" style="border-width:0px;">

Would you be able to post some screenshots to make this a bit more tangible for us? Redact any personal info of course.

I thought about it, but it's a private site so I think I better not. We can just drop it.

Appreciate your help :+1:

Have you tried the Wait for Front Browser to Finish Loading action?

If you wrote the code the way I intended, then the only reason the loop would never end is if the text in the window was never changing. You said the window would change. But since I can't see the window or the code, there isn't much more I can do.

Thanks again to @griffman, @noisneil, @Airy for your help. I'm sorry I wasn't able to provide more for you to go on, but I did solve the problem using pieces from all of your suggestions. Yay teamwork :raised_hands:

Here's how...

Set a variable to the original html:

Click on the found image "next" arrow/button, wait for the page to load, and set another variable to the new html:

Then, cobbling together a regex with much trial and error, reduce both variables down to the only the html of the content that would change if the page changed. This was the challenging part to come up with because much of the html would change on a page reload even if the content didn't change, but isolating the part that represented the content was key:

Then put all of this in an Until action with a text condition to compare these 2 variables so the actions would repeat until the variables were the same (the content portion of the html before and after clicking next did not change):

I know this is a sloppy hack, but it works and taught me a few things. I usually try to be more helpful to those helping me, so I really appreciate everyone's patience!