0

I hope you are all having a wonderful day.

I've been working on a school project regarding automation with Selenium in C#. I'm trying to optimize my application as best as possible, and am trying to block all unnecessary stuff on the page from loading/showing. I've read that one of the best ways of doing this is by making a custom iFrame, which can then block certain CSS or code from loading. What is the best way of doing this? I'd say I'm decent at C# and Selenium but I have no clue on how to code a custom iFrame or block CSS. I'd imagine you would need to use some kind of JS script for this?

Does anyone have any clue or possible idea's on what's the best way of going about this?

Thanks in advance!

I can provide some code if this helps.

Psychil
  • 1
  • 2

1 Answers1

0

You might be better off using a proxy (browsermob proxy is popular with selenium) in order to block specific requests (by resource or by domain). Here are some helpful links: http://elementalselenium.com/tips/66-blacklist
https://sqa.stackexchange.com/a/6865/34209
https://github.com/lightbody/browsermob-proxy

If you need to proxy to a proxy try this example: https://stackoverflow.com/a/62180862/1387701

DMart
  • 2,198
  • 1
  • 11
  • 17
  • Thanks for the answer and I will most certainly look into this! However I do not know if this can be combined with other proxies. Since at the moment I already use proxies set via Chrome settings. – Psychil Oct 25 '20 at 14:58
  • Perfect! Your proxy should be able to be configured to do this. What is your driver setup look like? And what proxy are you using? – DMart Oct 25 '20 at 15:11
  • I'm using proxies from: https://anonymous-proxies.net/ I don't think these have an option for this. I'm using the HTTP ones. It is kinda important that I find a solution that doesn't just work for me with the right setup, but works for anybody that opens the project and tries to run it. Since I've made the proxies configurable, and they would change per user. – Psychil Oct 25 '20 at 15:29