Capture script-generated postal code URI

Summary:

I am testing automation for webapp (using Selenium) and I am trying to grab the mailto: link (in particular, one of the request parameters) generated by javascript during the onclick event. Currently, the only way to do this is to duplicate the logic in my test function. This is not ideal, because it means that I will have to update the logic in the tests if it ever changes in webapp. My question is: can you come up with a better way?

Details:

Here's how webapp works:

  • listen to click event on div
  • if the purpose of the event is an "email button", generates a mailto: URI based on the current state
  • set window.location = [generated URI] in JavaScript

Unfortunately, as you can see, this URI generation occurs as a result of the onclick event and simply sets window.location to this URI, so it does not set it as an href attribute on the anchor (or any attribute on any other) element that I can request for the DOM.

I was also unlucky to find an event that fires as a result of setting window.location in mailto: URI, which may have a URI as one of its properties ... Perhaps I forgot it?

Any ideas?

+4
source share
1 answer

Have you tried calling a function that manually used storeEval in onclick and parsed the return value?

-1
source

All Articles