I'm currently working on a website which takes 2-3 MINS to complete the page load. Even after all the elements are visible,still browser keeps loading. I have figured it out that happens because the website contains social media links such as Facebook, Twitter, LinkedIn, Instagram etc. Facebook access is prohibited in where I am right now. SO browser took so long to complete the connection between those buttons and social media servers. I blocked Facebook from host file even but no luck yet. Is there a way to stop running scripts or stop making connections with those servers from those buttons.?
PS: I'm not the developer of the website. So cannot change anything on the code. I checked with chrome,Firefox and even with IE drivers. - no luck.
If all hope is lost, and those sites are actually blocked internally, and this is worth the effort than you can redirect the calls to a local faked site.
The easiest might probably be adding a static DNS Record for site X, and keeping a copy of the requested page on a local server.
On your browsers that run the tests install add-ons to block popups and external scripts. No-Script is a great on for Firefox, but each has their own. You will then need to go configure a white-list of what should be allowed and leave everything else blocked.
This will allow your site and test to run without any interference from third party site adds/scripts/etc... Just be sure you manually run through it and make sure it's set properly to prevent what you don't want and allow what you do want. Then the automation test would be able to run without interruption.
Thanks all for your concern on my problem. Finally I blocked facebook with host file in windows. I followed this Git repo.
Now its running smoothly.
PS: If u follow the same method then you will realize that you can no longer access facebook through your machine. Since this solved my matter I quit from looking for further solutions but If anybody else knows a way to block facebook connectivity through selenium please comment below.