Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Webdriver is detectable

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?

like image 317
Stevo Avatar asked Jul 24 '14 16:07

Stevo


2 Answers

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.

like image 142
JimEvans Avatar answered Oct 24 '22 05:10

JimEvans


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.

like image 40
Onkar_M18 Avatar answered Oct 24 '22 04:10

Onkar_M18