How to replace Chrome with PhantomJS for use with Selenium and Conductor? - selenium

I am successfully using the Conductor framework to scrape data off a website. I use the Chrome browser and therefore I have installed chromedriver.exe in the root of my project.
To speed things up I want to replace Chrome with the headless PhantomJS browser. I installed PhantomJS as explained in the answer to this Stackoverflow question: PhantomJS & Conductor Framework and have changed the browser to Browser.PHANTOMJS in #Config.
Whatever I do however, I get no results.
I found no documentation how to setup PhantomJS for use with Selenium or PhantomJS.
The question How to Implement Selenium WebDriver with PhantomJS and Can we Use Sikuli with PhantomJS? did not help either.
How to replace Chrome with PhantomJS for use with Selenium and Conductor?

The trouble you are having appears to be due to an older version of the PhantomJS library included in Conductor. The error when running PhantomJS can be found in this imported issue on the Selenium Github. The remedy is to import a fork of PhantomJS which works with the newer releases of Selenium.
You can easily implement this by editing the pom.xml file and swapping
<groupId>com.github.detro</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>${phantomjs_version}</version>
with
<groupId>com.codeborne</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.2.1</version>

You can use a headless chrome driver with selenium, as showed here:
https://duo.com/decipher/driving-headless-chrome-with-python

Related

How to run the selenium code on linux using firefox without GUI?

I had redhat Linux server command line but there is no GUI for that and I need to run selenium code on this server with firefox. As I am new to selenium so I am not sure whether it will work or not.
For achieving this I had install Firefox on my Redhat linux machine successfully but not able to trigger that as it is showing no display found.
Is there any other way to achieve this for headless browsing, where virtually a firefox will be opened and selenium code can be executed without GUI. Is it possible to do??
You can use HtmlUnitDriver of selenium to use headless browsing but it will not open firefox and may be not loading all content to it's cache as same as firefox
Refer Below:-
https://code.google.com/p/selenium/wiki/HtmlUnitDriver
Another thing you can use is Phantomjs with selenium Webdriver. This is most using pattern by industries for headless browsing
Refer below:-
http://www.guru99.com/selenium-with-htmlunit-driver-phantomjs.html
Yes you can trigger selenium file using command line
http://www.tutorialspoint.com/testng/testng_executing_tests.htm
Bash file is running fine in windows for testng but it is not working in linux/mac
Now if still your firefox is not opening then it is basically issue of some setting with your OS with firefox
Refer that too :-
https://serverfault.com/questions/279036/open-terminal-via-ssh-run-firefox-display-not-found
May be you have problem with some permission in red hat
Hope it will help you :)

Open phantomJS using robot framework with javascript off

Is there a way to open PhantomJS browser with JavaScript off?
I have used the following code but JavaScript is still enabled.
Open Browser url phantomjs desired_capabilities=javascriptEnabled:False
Thanks
Zied
No. The Robot framework uses Selenium to run web tests. The Selenium Webdriver support in PhantomJS is provided by Ghostdriver which is fully implemented in JavaScript and partially runs inside of the page context. If JavaScript would be disabled, then you couldn't use the webdriver protocol anymore to talk to PhantomJS.

Selenium Testing Safari Extension

When you attempt to run Selenium tests in a scripting context whose origin is at "safari-extension://...", the session hangs. I believe the problem is caused by extension sandboxing, which means if I get Selenium running in the same origin as the extension I am testing, it should be possible to execute selenium commands in my extension.
Question: Can I incorporate the Safari Driver into my Safari extension during testing to circumvent sandboxing?
We modified the Safari driver to navigate extension:// pages, and the problem persists. It looks like Apple blocks Selenium at the extension level :(

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

Error using SelBlocks extension with Selenium server

I've been recording/writing Selenium html scripts using the SelBlocks extension. Now we're going to use Selenium server to run the tests in different browsers.
I tried getting the javascript from the SelBlock xpi by extracting it and reference that javascript in my selenium server bat file. When I try to run my bat file with referencing the javascript, i got the error "Line: 777 Error: 'XML' is undefined" when I run it in Internet explorer. This happens as the test script is loaded in TestRunner.
When I try to run it in Firefox, TestRunner hangs just prior to running the script.
i'm using Selenium Server 2.1, Firefox 5 and IE8.
Selblocks is only supported for Selenium IDE. See note about "no language translation" here: Selblocks documentation. Although automated translation would be an interesting area of investigation...
I've tried the same thing (Firefox 4.0, Firefox 7.0, selenium-server-2.0.5.jar, SelBlocks 1.3 installed as a firefox plugin).
Since the -userExtensions way didn't work for me, I installed SelBlocks 1.3 in the firefox profile I use with -firefoxProfileTemplate and -htmlSuite. It looks like selenium server doesn't do anything.
After more than a minute I have:
so even the selenium elapsed timer doesn't tick, and no line gets executed.
My simple test case is here.
Looks like I can't use SelBlocks with selenium-server[version].jar for now?
ANNOUNCEMENT: SelBlocks 2.1 now includes support for Selenium Server. Get the extension file here: https://raw.githubusercontent.com/refactoror/SelBlocks/master/user-extensions.js
Initial browser support is for firefox, googlechrome, and opera.