How do I make selenium see the network requests made by a web browser? - selenium-webdriver

I have a dotnet Selenium web driver app.
When I'm testing the page one of the things I need to confirm is that a flash object on the page has pulled correct content from a content store on my site. (i.e. the flash object should be loading content from /stuff/info.txt and including that content within the animation.)
As a human looking at this I can use the chrome network tab and see that /stuff/info.txt has been accessed.
How can I make Selenium execute a similar watch and see the network requests made by a web browser?

I did not wrote this, neither tested it however someone did it here: http://www.softwareishard.com/blog/firebug/automate-page-load-performance-testing-with-firebug-and-selenium/
Basically all the requests are exported via netexport and firebug plugins inside a HAR (Http ARchive file)
Please give us your feedback if you give it a try!
Cheers !

I assume you want to automate the process which the developer tools of browsers does. Something like firebug but for verification using Code.
I don't believe Selenium has such features. For now, you will not be able to achieve this.

Related

How to find which file is serving ads in my application?

Ok, somehow I am serving ads in my NodeJS / AngularJS application, but I haven't include this myself.
There's some package or included link sending ads to the client, but the ads are not visible, and the adserve url changes with every request. (The url that can be seen in the screenshot below)
How do I find out which place in my application serves these ads?
PS: I am sure this doesn't come from my local dev pc, my other collegues have this issue as well.
A quick trick may be to search for the url in every files of your repository. If you use a cdn to load your librairies, try to look inside also (you can do that directly in chrome dev tool with ctrl/cmd f in the sources tab).
Hope it will help !
The "adserver" in my project turns out to be a tracking / analytics beacon included by the Realtime.co framework.
Thankfully, the author responded to my email very quickly, and they also provide a beacon-free version of their framework. So problem solved :)

How do I stop Angular from loading the .angular.min.js.map file when pulling Angular from a CDN?

I am working on a website which loads AngularJS from a CDN, and along with Angular it loads a 284KB map file (angular.min.js.map), which I understand is for debugging.
I don't want to debug, this is going into production, and 284KB is a lot! How do I stop this file from loading?
I can't edit the file (CDN), and it doesn't matter what my Google Chrome options are, I can't advise others to change their settings to use the website I am working on.
Thanks
According to http://blog.teamtreehouse.com/introduction-source-maps
The developer tools will only load this file if support for source maps is enabled and the developer tools are open.
So any impact will only be felt if someone opens their developers tools, which I suspect is acceptable, as in that case ability to debug it more important than download speed/size.
Within Google Chrome's inspector, have you unticked 'Enable JavaScript source maps' in Settings > General?
I think your dev setup is trying to pull the source map file in regardless, for others without this option ticked in Chrome's inspector it won't be a problem.
Don't worry about the source map files for production.
Only if a user has chrome dev tools or other source map compatible browser tools running will they request and download the source map file/s.

Browser Automation with Selenium: Fingerprints, recognizability and traceability?

I want to use selenium/webdriver to simulate a browser and scrape some website-content with it. Even if its not the fastest method, for me it has many advantages such as executing scripts etc.
For many websites it is forbidden to access them via an automated method, for example search engines like google or bing.
For one tool i need to scrape the estimated resultstat from google for several keywords. This will look like the following: simulate the browser that visits google.com and types in a keyword and scrapes the results, then after a little pause type in the next keyword, scrape the results and so on...
My question is: Is it possible for a website to recognize that I'm using selenium to simulate the browser instead of using the browser by hand? Especially the google case gives me some doubts. I know selenium is partly developed by google or at least by some guys working for google. So does leave selenium some fingerprints or isn't it possible to decide if I'm using the browser by myself or simulated by selenium, even for google?
No, nobody can actually see that you're using Selenium and not hand-operating the browser yourself with WebDriver. I'm not sure about the old Selenium RC, but it should be the same way. Here's how it works:
Selenium opens up a browser with a clean profile (or with a profile you selected)
Selenium is hooked up to the browser so it can steer it, control it. But the browser still does most of the work. Basically, Selenium replaces the user inputs to the browser, but not more.
You can easily verify this by reading the contents of the HTTP headers sent by your browser.
If you ever actually needed Selenium to be recognized by your server, you can use Browsermob-proxy and add a custom header to your requests.
All that said, there is one thing you must be aware of. While there's no way to detect Selenium directly, there can be some indirect clues picked up by the website you're visiting. Those usually include scanning for too many requests made in virtually no time - this might be an issue for you. Make sure your Selenium is behaving like a user.
EDIT 2016/04:
Apparanetly it is possible as https://stackoverflow.com/a/33403473/2930045 states that a company can do it. My guess - and it is nothing but a guess - is that they can run some JS that Selenium installs into the browser to operate.
Signs point to yes, sites are able to regonize that you are using Selenium.
Counter Example: www.stubhub.com detects and blocks my browser instance launched using Selenium while "normal" browsing done manually (not using the browser launched by the Selenium web driver) work with out issue.
See this stackoverflow question for additional details
Can a website detect when you are using selenium with chromedriver?

How to completely hide the ExtJS Source Code in browsers inspect element?

I have an EXTJS app and when I look at the source by using browser's inspect element I can see my entire app's source code (except for the server-side code ofcourse.).
I have seen some extjs apps that when inspecting theie source code, all I can see is the app.html page and non of their .js files is discover able by the browser.
I was wondering how I should configure my EXTJS app to make them not viewable inside the browsers "Sources" tab (ie. Chrome's Inspect Element > Sources).
Any help is much appreciated,
The best you can do is to obfuscate your code, as there is no way to stop someone looking at it once its got to the browser.
Even if the browser could hide it somehow, there is nothing stopping a user sniffing the packets on the network etc.

Checkboxes disappearing when uploading to Google App Engine

I have written a controller to take input from the form containing a list of options. The options have to be selected using checkboxes. I have successfully tested the code on my local machine. But when uploaded to the app engine, the webpage is not displaying the checkbox fields. It is not displaying the options either. I tested with 3 browsers - IE, Mozilla and Chrome and this happens everywhere. But, everything is working on fine on the browsers when running on local machine. I am quite confused as to what is going wrong.
Please help me fix this issue.
Thanks in advance...
You likely need to setup static file/directory mappings in app.yaml.
You need to provide us with more details to help you debug issues. For example, if the browser doesn't display what you expect tell us what it does display. What happens if you view source? Is your HTML there?

Resources