Does phantomjs cover more than just chrome? - phantomjs

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.

Related

How to configure Selenium tests to make IE8 testing possible on Windows 10

I installed and successfully run IE11 tests with Selenium.
Is there any easy setup to force run IE8 for testing with Selenium?
According to https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration there is nowhere mentioned how to run specific - here IE8 - version of IE and by default IE11 is run.
Should I have installed IE8 first to make those test run?
It is impossible to run IE8 on Windows10 because this is not supported configuration as #BoldClock mentioned in comment to my question.
To make this happen VirtualMachine need to be downloaded form https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ and run to make IE8 tests available.
Similar question:
Can I install IE7 and IE8 in Windows 10?

how to detect selenium/webdriver browsing on my site

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

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.

Use phantomjs to drive chrome

Is there a way to use phantomjs to drive my firefox/chrome browser?
We have a bunch of casperjs tests, that I would like to run directly in the browser for debugging ( or just pure interrest ).
I seem to recall that a long time ago, before phantomjs became pure headless, I could do this by making it run on X instead of xvfb and removing/uncommenting the phantom.exit() line.
PhantomJs IS a browser, so the answer is no. You may want to look into Karma however.
You just use a config file which allows you to provide a browser to run your tests in:
Chrome
ChromeCanary
Firefox
Opera
Safari (only Mac)
PhantomJS
IE & Edge (only Windows)
SauseLabs, BrowserStack Electron, & more
Still, your tests will need to be written in QUnit, Jasmine, Mocha, ... which can be too much work to port from CasperJs.

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