how to detect selenium/webdriver browsing on my site - selenium

Does anyone know how to detect selenium/webdriver browsing on my site?
I don't want to block them, just detect them.
I saw this question:
Can a website detect when you are using selenium with chromedriver?
But trying all of these on latest version didn't seem to work.
Any body knows anything else?
P.S. please don't leave answers/comments of "dont block"/"you are looking in the wrong place" - I am fully aware of what I'm asking and what will be the business logic to use it.
-- EDIT --
Things I have tested from the link above:
detecting cdc_asdjflasutopfhvcZLmcfl_ key on elements, mostly on window and document but some other elements we have across the entire site.
Searching for window.navigator.webdriver always returns undefined instead of true (tested on both chrome and firefox although only firefox said to support it)
tested the script from this answer: https://stackoverflow.com/a/45814390/1593987
All tests were done using latest selenium, browsers (firefox and chrome), and latest webdriver plugins. for now only on windows, but will probably test ubuntu as well.

In recent versions of Selenium WebDriver it's handled on a spec level.
There is a read-only JS property - navigator.webdriver which is true in case webdriver is used to control browser.
Checked with Chrome v73 - returns true.
References:
Spec - https://w3c.github.io/webdriver/#dom-navigatorautomationinformation-webdriver
Firefox - https://developer.mozilla.org/en-US/docs/Web/API/Navigator/webdriver
Chrome - https://www.chromestatus.com/feature/6216034532982784

Related

Selenium performance with InternetExplorerDriver and IE11

I am facing a very slow response when running my scripts on IE11. Sometimes, I get FocusWindowsClosed, ElementIsNotClickable. I have changed the zoom settings for all zones, created feature BFCACHE for IE in feature control, added capabilities into my code but nothing works for me. If anyone has any idea why I am facing this issue. Do i need to downgrade window or IE versions? I have also downloaded the same version of selenium client server with same IEDriver which is (3.8.0).
To start with, Selenium v3.8.0 of 2017-11-30 is more then 2 years older. Even the error trace logs would be difficult to debug. So as per best practices you may like to:
First of all, the fact that ...64-bit IEDriverServer executable populate the input fields with the character sequence very slowly as compared to 32-bit IEDriverServer executable.... is a known issue.
You can find a detailed discussion in IEDriverServer sends text very slowly using Selenium to the search field
Ensure the Internet Explorer Protective mode setting are properly configured.
Ensure the Zoom level is properly configured.
Ensure ignoreProtectedModeSettings is properly confugured.
Ensure setting up selenium to work with internet explorer.
Ensure FEATURE_BFCACHE is properly confugured.
Upgrade Selenium to current levels Version 3.141.59.
Upgrade IEDriverServer to latest IEDriverServer v3.150.1 level.
Note: As per best practices as Selenium Client and InternetExplorerDriver are released in sync and you must try to use both the binaries from the same major release.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Execute your #Test.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
tl;dr
A couple of references:
Internet Explorer 11 getting stuck randomly while executing tests through IEDriverServer and Selenium
HTTP Status: '500' -> incorrect JSON status mapping for 'timeout' (408 expected) while clicking element with IEDriverServer Selenium and Java

What are the benefits of using Marionette FirefoxDriver instead of the old Selenium FirefoxDriver for a Selenium tester?

Last weeks there has been a lot of noise about this new FirefoxDriver called Marionette. To use Firefox with Selenium, we used to use the "old" Selenium FirefoxDriver. From Firefox 48.0 onwards it is going to be required to use this new FirefoxDriver developed by Mozilla.
I understand it is required to change to that direction to get every browser supports and develops its drivers and to get drivers independent of Selenium. Besides, it is supposed if Mozilla develops its own driver, it will be faster and easier to fix issues and to develop features.
My question is, for those who create automated tests using Selenium framework, is there any benefit of using Marionette instead of the "old" Selenium supported FirefoxDriver? _(Such as a better performance, a better compatibility...)
The main advantage for using the Mozilla-provided, Marionette-based Geckodriver solution is that it works for versions of Firefox 48 and higher. The legacy driver provided and maintained by the Selenium project doesn't work for Firefox 48 or higher, and will never work for those versions of Firefox.
The legacy driver is implemented as a Firefox extension. This extension is installed in the profile used by the driver when WebDriver launches Firefox. Firefox 48 introduced two new features that disabled this browser extension. The first is the so-called "electrolysis" feature, or multiprocess Firefox. Electrolysis changes the way extensions have to deal with the browser in ways the Selenium team has not taken the time to fully understand.
The second, more important requirement is that all browser extensions must be signed by Mozilla before the browser will allow them to load. This latter feature has been in Firefox for several versions, but beginning with 48, it can no longer be disabled. The WebDriver browser extension introduces several valid security concerns for the Firefox browser, and as such, will not be signed by Mozilla's security team. This, in turn, renders the extension inoperable, and thus Selenium can no longer communicate with Firefox. The Marionette-based solution, being developed and maintained by Mozilla in the first place, is blessed by them for use in automating Firefox, and as such carries a commitment that it will continue to work with future versions moving forward.
So the primary benefit of using Marionette with Firefox 48 and higher is that it will work, whereas other solutions won't.

Selenium scripts fail after newest Windows update

I have a question regarding Selenium and the current Microsoft updates:
I just installed the newest Microsoft patches on a PC and now the Selenium scripts won't work anymore. I'm using the Selenium IE Driver 2.44.0 in the scripts. Maybe something has changed in the Internet Explorer, I'm not sure. Suddenly the scripts can't find any web elements on the page anymore. An InvalidSelectorException is thrown because the findElements methods can't be executed. The IE driver opens up and it navigates to the given URL, but when it tries to find a web element, the script fails. I also tried it out on a PC which hasn't the newest updates installed yet and the scripts are working fine there, there are no problems at all.
Do you have any ideas what to do or what could be the cause?
Thanks a lot!
Yes as I stated here
If you have taken windows update KB3025390 IE will not work as expected. There is currently no resolution to that yet.
Also, Uninstalling the update KB3025390 should make the WebDriver work correctly with Internet Explorer 11. See this answer

Does phantomjs cover more than just chrome?

Phantomjs is webkit based. That means of the major browsers it's really only emulating Chrome, right? Does it provide a mechanism (or is there a way to force it) to provide sufficient test coverage for other browsers, aside from wrapping it in Selenium?
No. Current PhantomJS is a version of WebKit that is roughly equivalent to Chrome 13 or Safari 5.1, but it is neither of those browsers. (Chrome and Safari behave differently too.) (BTW, PhantomJS 2.0 is hopefully going to have the webkit separately linkable, so you can use different versions.)
If you move to using CasperJS, then your same script can (usually) run with each of PhantomJS and SlimerJS, which will give you test coverage for both WebKit and Gecko (Firefox). SlimerJS also allows you to directly use a local installation of Firefox instead of the supplied Gecko engine, if you wanted to test against different Firefox versions.

Run Geb tests with chromeDriver without opening the browser

I want to run my Geb specs with chrome driver without having to watch the tests on the browser? can this be done?
P.D.: I know I can use the HtmlUnitDriver, but this driver sometimes gives my errors (caused mainly by timeouts) that the chrome driver don't.
There is currently no way to do this with Chrome, Safari, Opera or FireFox, however there are multiple options you can do. First is to pipe the "window" into a virtual frame buffer (if you're using Linux). This process will pop open the browser, only in memory. I talk about this in my blog post (http://www.ensor.cc/2011/05/maven-javascript-unit-test-using.html) during the maven pre-integration phase
The other option is to use the brand new GhostDriver. GhostDriver is a WebDriver implementation of PhantomJS which is a headless WebKit. This is WAY better than HtmlUnit but still has some features being built out. GhostDriver is currently not in Maven Central, so you will need to manually add it to the common repository. You can then use it as a WebDriver. This has worked for me with moderate success (90% of my test cases dropped in without any changes needed).
Read this first: http://blog.ivandemarino.me/2012/12/04/Finally-GhostDriver-1-0-0
Then refer to the GitHub README and code: https://github.com/detro/ghostdriver