9

I read everywhere that it is not possible for websites to detect that a user is using a selenium webdriver... but why?

For example the webdriver plugin in firefox adds an 'webdriver attribute' to the <html> element. So the <html>... goes to <html webdriver="true">...

I am confused... why it is not possible to detect the webdriver?

I wrote a little Javascript to get the document.outerHTML... and there is the webdriver attribute! = detected!?

Here is my code I tested in Browser with Webdriver and without:

<html>
<head>
  <script type="text/javascript">
  <!--
    function showWindow(){
      javascript:(alert(document.documentElement.outerHTML));
    }
  //-->
  </script>
</head>
<body>
  <form>
    <input type="button" value="Show outerHTML" onclick="showWindow()">
  </form>
</body>
</html>

Please can somebody explain me why it is not possible to detect the Webdriver?

Stevo
  • 93
  • 1
  • 1
  • 6
  • 1
    Could you explain where you got the "webdriver plugin in firefox"? – SiKing Jul 24 '14 at 16:20
  • It is pre-installed in the FirefoxDriver, but sry it is not a Plugin. It's an addon – Stevo Jul 24 '14 at 16:27
  • Does it look like this: http://docs.seleniumhq.org/docs/02_selenium_ide.jsp#opening-the-ide ? – SiKing Jul 24 '14 at 16:29
  • No it's not the IDE... It has no GUI, I just found it under Addons and its named: Firefox WebDriver 2.42.1 (Author: Simon Stewart) – Stevo Jul 24 '14 at 16:35
  • 1
    OK, I am not exactly sure what you have, but I have a **guess**. https://en.wikipedia.org/wiki/WebDriver#Selenium_WebDriver says: "As of early 2012, Simon Stewart ... [was] negotiating with the W3C to make WebDriver an internet standard." I do not know what your addon does, but this is not the Selenium test automation tool. – SiKing Jul 24 '14 at 16:54
  • 3
    Your problem here is that it's not a cross-platform **or** cross-browser solution to "detecting" WebDriver. You are right, it is set but *only* in the FFDriver. Therefore your detection methods will fail on every other browser. Also worth mentioning the FF Driver will eventually be replaced with Marionette - so this solution may not even continue to work. However, nice find, it's set on the initial page load: [source](https://github.com/SeleniumHQ/selenium/blob/d5fbbd43adecb829134167017c66722dcc06b491/javascript/firefox-driver/extension/content/dommessenger.js#L98) – Arran Jul 25 '14 at 10:11
  • @Arran thank you. Until now my experience with selenium are based on FFDriver only. I will testing this with other browsers in the next days and keep updating my results here. And thanks for the source link – Stevo Jul 25 '14 at 14:11
  • 2
    The Firefox add-on you're seeing is the current implementation of the `FirefoxDriver`. The driver creates an anonymous profile, into which is installed a Firefox extension that provides the actual implementation of the driver. As mentioned elsewhere, future versions of the driver will not rely on an extension to drive the browser, but will use technology provided within the browser itself (also called "Marionette"). – JimEvans Jul 25 '14 at 21:59

3 Answers3

4

The W3C draft spec states in Appendix E that drivers should provide a mechanism for fingerprinting that a browser is being driven by WebDriver. At the moment, no implementations comply with this section of the spec. The Firefox driver currently comes closest, adding an attribute to the html tag. Future versions and drivers of other browsers will likely implement methods of detection in line with the specification.

JimEvans
  • 27,201
  • 7
  • 83
  • 108
2

Yes selenium is detectable.check Can a website detect when you are using selenium with chromedriver? If some one is using Firefox driver for automation then it is easy to detect if you put this code at your client side

        try{
        if(window.document.documentElement.getAttribute("webdriver"))
            alert("Caught in 1st case :- Selenium Webdriver is banned!!!");
        }
        catch(Exception){}
        try{
        if(navigator.webdriver)
            alert("Caught in 2nd case :- Selenium Webdriver is banned!!!");
        }
        catch(Exception){}`

But same code doesnt help if you are using chrome or IE driver.

Community
  • 1
  • 1
Onkar_M18
  • 2,601
  • 1
  • 13
  • 12
1

I'd have to side with SiKing in that whatever addon you're using isn't part of the actual Selenium tools. Can you post a link to your addon? Maybe that would shed some more light.

Generally speaking, WebDriver simply automates the usage of a browser with the intent of replicating the actions of a human user as closely as possible. This, in and of itself, will be invisible to the server. Unless you're altering your browser's user agent, there would be nothing for the server to easily see to indicate any sort of automation in use.

However, while I've only recently begun studying this, repeated automated usages of an application may present patterns in server logs that could be far more consistent than a human user as far as interactions with an application. If you're using Selenium to scrape a site, for example, you could be leaving some fingerprints just due to the nature of an automated session. Things like extremely consistent click, inputs, page requests, etc. could be forming noticeable log patterns that could potentially expose automation.

Now, unless you're generating a lot of traffic or a lot of repetitive actions on the system, you're unlikely to be noticed. It would take something generating fairly abnormal in the logs, or a very observant sysadmin to trigger any sort of manual investigation... and even then, someone would have to know what to look for to make an accurate determination.

tim-slifer
  • 1,068
  • 1
  • 9
  • 17
  • Thanks. But this addon is pre-installed in the FirefoxDriver so I can't provide a link to it. I know that inhuman actions will logged and can expose automation but that was not my point. I am just confused about the 'WebDiver = true' attribute on the initial page load when using the FFDriver. @Arran 's comment brought some light into – Stevo Jul 25 '14 at 14:48
  • @Stevo Indeed, Firefox profile contains an addon which is merely "the javascript server part" of Firefox webdriver. The tag webdriver=true can be removed without problem. U can extract the addon the upload it elsewhere, then have a link to show ;-) but the better if simply ask people for looking the sources. – m3nda Nov 06 '16 at 22:46