1

I'm developing a tool that will browse a site doing a series of actions (clicks, filling forms) and record all the HTTP petitions to verify implementation error/changes

I'm using:

  • Python 3.6
  • Selenium
  • Browsermob proxy

The tool does exactly what I want, it records all the petitions into a single HAR file, my problem is that I can not know which petitions are from what page. What I would like to have is a listener that when a new page is loading start a new HAR page and thus have my information segmented.

Thanks a lot for your help

Enrique26
  • 23
  • 3
  • 1
    I don't know the application under test but how can you not know when a new page is loaded? normally this is triggered by a certain action like submitting a form or something similar. Could you please describe in more detail how this transition from one page to the next is working? – AlvaHenrik Sep 18 '18 at 11:02
  • right now, I'm able to know when a new page is loaded because I test it manually and hardcode the creation of a new har page. But my idea is to have this as a microservice and let the tool be able to detect if a click triggers a new page or not. – Enrique26 Sep 18 '18 at 12:20
  • As I still can't fully imagine how that looks like, I don't know if that will work, but if you interacted with an element and that interaction triggered a page reload you will get a StaleElementException if you try to do something on that element. So after clicking an element you could try to get the tagname or some other "cheap" operation. If you get a StaleElementException you know that the reference to that element was lost. Most likely due to a page reload. You might also have to take some execution time of scripts before the page load into account. – AlvaHenrik Sep 18 '18 at 13:06

0 Answers0