Using selenium grid to execute remote code - selenium

We looking to use Selenium grid to parallelize our tests but some of our tests need to run java code local to the testing machine. In other words as well as automating the browser we also need to run some java code on the test machine. Are there hooks in Selenium Grid that will allow us to do this?
PS we are also looking at Jenkins to setup our environment.
EDIT: To be clearer, the java code I need to execute does a get from the web application, downloading pdf files that we cannot do with selenium alone. It then does some processing on those PDF files. I suppose the processing could be done on the server hub but the downloading can't. Unless someone can explain how to download a pdf using selenium and save it to a given location?

Selenium cannot execute your java code in the remote control machine. It will get executed only in the hub machine. However, taking screenshot, deal with popup, uploading the files in a specific path can be taken care by Grid.

Related

Can we execute/trigger selenium automation scripts through UFT

Using Webdriver, I have automated web based Application in eclipse and using QTP, I have automated Power Builder application(like desktop App).
Now both become depended module for me, from PB data's are flowing to web base application.
so, how can I achieve this. please someone provide me how to proceed with situation and give me some strategy to proceed
We have exactly the same situation where powerbuilder application is integrating with the web application, below is the solution we have followed
We are using jenkins for executions, but this can be done without jenkins also.
We have one jenkins job which executes a UFT test first and then executes the selenium test if UFT test is successfull.
At the end of test execution UFT test will generate a file with the information required by selenium test and then jenkins will trigger selenium test, selenium test will read this file to gather any required information.
Results are interpreted in the following way
If UFT test fails then jenkins will not trigger the selenium test. If the whole jenkins job is executed successfully then integration is working, if the UFT part failed then Powerbuilder is having issue and if selenium part failed then web application is having issue.

How to get selenium server running locally?

I need to have selenium server running in order to run some tests I'm creating in http://seleniumbuilder.github.io/se-builder/
This is not for the selniumIDE and not for a server grid, I need to be able to export from selenium builder and am directed to run them on a local selenium server, e.g. localhost:4444
I use the download page at http://www.seleniumhq.org/download/ but there isn't much info on basic stuff.
I see the link for the download and I can save the .jar file Now what? I don't know Java. Trying to click thru gets
[
[
How should I be compiling and then using it?
Selenium means different things depending on context.
Do you want to record/playback simple web browser interactions? You want SeleniumIDE or Selenium Builder. You need a standalone jar when replaying the tests from the command line; I think the docs tell you how but I couldn't find it. This small blog post tells you how. Essentially: download the Selenium Standalone Server jar file from SeleniumHQ and run it something like this:
java -jar c:\selenium\selenium-server-standalone-2.21.0.jar -htmlSuite "*firefox" "http://localhost:8080" "c:\test\my-test-suite.html" "c:\test\my-test-result.html"
(Note: even though it is called a "server", in this mode it does not listen on a port for incoming requests or anything like that; to most people's way of thinking, the jar file is actually a client in this mode, and the browser that it connects to is the server! The jar file does include a server, you're just not using it when executing a Selenese file like this.)
Do you want to run tests locally from your unit test runner (JUnit, NUnit, etc.?). You probably don't need a server. All the instructions are on this doc page.
Do you want to run the tests via a grid of multiple browsers, allowing you to distribute the load and do multi-browser testing easily? This is where Selenium server shines. Everything you need to know is on this doc page.

Running automated tests in client machine

Basically my requirement is :
I have developed a framework using selenium webdriver,maven and testng for a application under test.
Now i have to pass that on to the client without sharing the source code ..so that if he wants he can run the test in his machine without having everything else installed ..except java. and the output should be stored in one of the specific folders of the client machine.
Can i use any plugin in maven which will store the result or copy the result file to any folder of client machine.?
Please guide me how to achieve this.. how to pass on the above to client so that test run smoothly in his machine .
is there anything i need to take care while am using maven in the project?
I am using chrome browser to run the tests..
The application under test is available to be accessed from any type of browser.
kindly suggest.

Launching Selenium test from bookmark?

I have some Selenium IDE scripts for automating tasks (deploying to an internal server via it's web interface), and I want to have bookmarks to launch them.
Don't want go to Tools -> Selenium IDE -> search test -> launch test, just want to click a bookmark and let the script run.
How can I achieve this? Am I missing a point?
Don't know if it makes a difference, but I'm currently using Firefox (if I have to change browser for this, it wouldn't be a problem).
Thanks
Not sure whether you be able to run tests pressing on a bookmark as browser plugins are usually run with a key combo. And bookmark is URL. Well the main issue in your question how to associate bookmark
with browser addon launching.
Well, I've investigated a lil bit workaround. Speaking about getting Selenium HTML Test Suites Running Automatically (i mean an alternative to bookmarks) some solutions are possible:
solution 1:
Patch the Selenium server code to support HTML suites.
Build a script to execute your HTML test suites.
Build a script to read the suites’ output reports and consolidate
the information for inclusion into your CC.NET report.
Setup details you can get here
Solution 2:
Selenium IDE plugin for Firefox to create tests
Java to run Selenium Server
Selenium Server to run test suites
Nant to generate reports for CruiseControl.NET
CruiseControl.Net as a continuous integration engine
Setup details here
Hope this be useful for you.
Bookmarks are nothing else than URLs, which makes it impossible to "bookmark" a functionality of a plugin, such as the Selenium IDE.
However, there might be other plugins out there that do what you want. I haven't had a closer look at it, but one candidate could be the Favorites (Selenium IDE) Firefox Add-on.

Selenium: Is there any JS (JavaScript) code coverage tool which we can integrate with Selenium Server/RC

Selenium: Is there any JS (JavaScript) code coverage tool which we can integrate with Selenium Server/RC
Hi,
I want to JS code coverage done by my Selenium Test Suite
Is there any code coverage tool which can be integrated with my existing selenium rc framework??
In theory, you can use any coverage tool that instruments JavaScript code to collect coverage data.
For example, you can use JSCoverage either in proxy mode (for real-time instrumentation) or for static instrumentation to run your Selenium tests off the instrumented code.
One technical hurdle could be to devise a way to accumulate coverage data across multiple pages. The coverage tool of your choice could already have support for accumulation of data from multiple page runs. If not, you might have to handle that bit yourself, but this is probably not something trivial.
I have found the solution for my need, there are multiple tools available but I want a tool which can be integrated with my existing automation easily
Tool is JSCover
http://tntim96.github.io/JSCover/
Just run the Server
Run Server
java -cp JSCover-all.jar jscover.server.SimpleWebServer . 8080
Run Proxy Server
java -jar target/dist/JSCover-all.jar -ws --proxy --port=3128 --report-dir=target
Add Proxy in your Webdriver for port specified, 3128 in my case
After execution of test Generate Reports using
((JavascriptExecutor) driver).executeScript("jscoverage_report();");
You can add this line where you exit WebDriver or Test Case
Not aware of a tool for Selenium, but JsTestDriver has a design very similar to Selenium RC (can launch tests from the command line and they are run on a server that drives browsers headlessly) and provides code coverage information.
IntelliJ integrates with JsTestDriver and provides a visual display of coverage information.
Take a look at https://github.com/yui/yuitest/wiki/Code-Coverage
I've integrated this tool in my Selenium tests a time ago. You need a bit of work to gather coverage info before page changes (in any case js trigger a page reload, link etc...)
Once you set up everything, it will fully coverage any js executed while Selenium load and test your website pages.
PS : Even if it was specially adapted for YUI test, you can use it with selenium.
I don't know what you are trying to achieve, but:
Selenium is testing the final output, as seen on the page itself.
So it really does not matter if its PHP, HTML, JSP, ASP or .NET - the Selenium is designed to mimick the end user and click the final application - the final HTML code generated by whatever is under the hood.
Selenium is also not that good for code coverage tests - one piece code can be on many pages - so better approach with selenium is to do the "user" coverage - try to cover all the possible actions which living human could possibly do with your page
There is no particular tool that can integrate with Selenium to do JS coverage. However there are lots of tools which test JS on every page which can tell if the JS that executing on your web page had any errors. This may not ideal solution but on each page you will have the measure of uptil which point JS executed properly on your webpage under test. There are two solutions for that:
1.) JSErrorCollector API: It will integrate directly with Selenium and let you know if there were any error on the page. Can be found at: http://mguillem.wordpress.com/2011/10/11/webdriver-capture-js-errors-while-running-tests/
2.) Full fledged JS coverage tools: There is an excellent list of tools here which will essentially help you in covering JS on on your web pages. Can be found at: JavaScript unit test tools for TDD