0

I am testing multiple webpages and I need to automatically check webpage sources as in Google DevTools. What I aim to achieve is to check, whether a source is present, so for example, if you look here, I might (for example) want to check if source developer.google.com exists in this list.

This is what I Meant: Sources

What I have is:

|---------------------|------------------|------------------|
|       Command       |      Target      |      Value       |
|---------------------|------------------|------------------|
|  execute script     |  return["U1",..] |  websiteArray    |
|---------------------|------------------|------------------|
|  for each           |  websiteArray    |  iterator        |
|---------------------|------------------|------------------|
|    echo             |  ${iterator}     |                  |
|---------------------|------------------|------------------|
|    open             |  ${iterator}     |                  |
|---------------------|------------------|------------------|
|  end                |                  |                  |
|---------------------|------------------|------------------|

Is this possible in Selenium IDE? I would like to include this functionality in the for each loop, I haven't yet found any command that would seem to allow this in vanilla Selenium IDE, nor have I found any plugin.

Thanks

6
  • 2
    Why you want to check this ? – PDHide Nov 13 '20 at 14:41
  • Even if you could do it in Selenium IDE, it sounds hacky to me. Why not find a tool that's geared towarsd what you need in the first place? I'm thinking something like Puppeteer. – pavelsaman Nov 13 '20 at 15:37
  • You'll want to use a tool that has access to the dev tools, puppeteer for example. I'm not sure if if can access Sources, but worth a look. You'll need to know JavaScript to use puppeteer. – Lee Jensen Nov 13 '20 at 16:18
  • I do not know puppeteer unfortunately, I prefer gui where I can. I work with python, so I might as well look into Beautiful Soup and its functionality. @PDHide need to check if multiple websites have a third-party <script> tag inserted in <head></head> and are communicating with a certain analytics platform. – Raymond_90 Nov 13 '20 at 18:33
  • So what actually matters is whether events get sent to that platform? You're testing the implementation, not the behaviour. – jonrsharpe Nov 13 '20 at 23:02
2

In the end, I just used:

var scripts = Array.prototype.slice
    .apply(document.querySelectorAll('script'))
    .filter(s => s.src)
    .map(s => s.src);

var stringScripts = scripts.toString();

var n = stringScripts.includes("url I am looking for");

console.log(n);

I have a simple for loop and I apply this to every page and then I just read the console, it seems to work consistently.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.