Selenium Grid + Maven 2 - maven-2

Is there a good tutorial or does anyone have experience with setting this up ?
I have a Testsuite.html which launches my tests in one browser atm. This is done in the integration-test lifecycle by the maven selenium plugin. I want to run my tests on multiple browsers. I couldn't find any documentation about selenium grid + maven. I hope somebody can help me.
Thanks in advance, kukudas

Selenium Grid and maven are really not much different than Selenium and maven.
Grid is basically a drop-in replacement for selenium-rc. In our current setup we let the automated build system use Grid. It does this by simply changing the selenium-rc url (which is normally localhost:4444) to the grid's url.
Additionally we specify the browser string (*firefox, *iexplore, *opera or whatever) as a system property on the mvn command line, which we pick up when we initialize the selenium client libraries in our code.
So the way we've done it we basically set up 4 different build projects with different browser strings.

Related

Is it okay to place selenium and appium classes to src/main/java package or in src/test/java

We are creating a Selenium and Appium project in eclipse.
I was wondering if there are rules or right practices or correct location for Selenium and Appium classes?
During our training on Selenium, I notice that location of classes are in src/main/java.
While in our training on Appium the location of classes are in src/test/java.
Is it also okay to put the Selenium classes src/test/java?
Will there be any problem?
Or is it also okay to put Appium classes in src/main/java?
Will there be any problem?
What will be the best practice for locations of Selenium and Appium classes?
FYI, there will be no other code for the application. Just the Selenium and Appium classes.
TIA
Q. Is it also okay to put the Selenium classes src/test/java? Will there be any problem?
Ans: Yes it's absolutely fine, if you entire project is meant for test automation. There won't be any issue.
Q. Or is it also okay to put Appium classes in src/main/java? Will there be any problem?
Ans : Answer is again No
Since you've mentioned
there will be no other code for the application
It really does not matter if you keep your code in any one of the folders
Since It's a Maven project, main/java is for development and test/java is for unit test. Nothing more nothing less, it's all up to you to decide which one to go for.
Cause if you are using TestNg, in xml you would have to give the full file path in order to run the class file, so it does not really matter.

Setting chromedriver as the default for use in Geb tests inside IntelliJ

How can I set IntelliJ to recognize chromedriver as the default test browser to use for my automated Geb tests?
I have two IntelliJ projects, one that is configured and running properly hitting the targets I want, and one that has outdated code that I'm trying to bring back to life.
In the good project, when working with Geb tests, I'm able to reference the instance of Browser without actually defining it.. I.E., I can say
go('google.com')
and it works. In the project I'm trying to update, I have to define an instance of browser, and then append browser to all of my commands. Example:
browser.go('google.com')
It seems that if I don't call browser.go, it defaults to some type of phantomJs or headless (maybe htmlUnit?) browser to run the tests.
I don't see anything in the pom.xml file that would indicate to do this in EITHER of the projects, and in the good project there is no driver defined inside of the GebConfig.groovy, so I'm a little confused on where this could be set.
You configure the default browser in your GebConfig.groovy. From there you can reference the system property geb.env which could be set from Maven or Gradle. I usually build all my Geb projects with Maven, using this variable to set the default (which could still be overridden via command line). When importing the Maven project into IntelliJ IDEA, the IDE will respect the Maven setting.
For basic introduction about geb.env see the Geb manual.
In your pom.xml look for something like <geb.env>phantomjs</geb.env> and change it as needed.

Selenium IDE or Builder, can they connect with Selenium Server 2?

Is there any possible way to execute the output of either Selenium IDE browser plugin or Selenium Builder plugin with the selenium-server-standalone.jar?
When I try to execute the Selenium IDE selenese output with the -htmlSuite flag of the selenium-server JAR, the server complains that sendKeys is not a valid command. sendKeys is a selenium V1 command, but the Selenium IDE outputs V2. You'd think the server could execute V2 syntax, but it can't.
When I save V1 syntax from Selenium Builder, and try to execute that with the -htmlSuite flag I get an error that "click" does not implement the event interface. (I'm guessing some other v1/v2 incompatibility)
There doesn't seem to be a way to execute the JSON output of Builder against the server either (there's a Jenkins plugin that claims to do this, but it doesn't seem to have enough logging or debug information to tell if it did anything at all).
Is there anyway to run the output of any GUI tool against Selenium Server 2?
UPDATE:
According to this bug, the selenese runner part of selenium server is abandoned. https://code.google.com/p/selenium/issues/detail?id=4349 But why would someone bother compiling, packaging and shipping abandoned code that doesn't work? I find it really hard to believe that something as popular as Selenium doesn't work with its own IDE browser plugin.
Yes, you can. First, do your research in the Selenium documentation and start a Selenium Grid on your computer. Then, you can use Maven to run Selenium Builder scripts (using a method like what I have done here: http://djangofan.github.io/maven-selenium-builder/ )
Of course, for the Builder scripts to connect to the Grid hub you need to change the calls to:
new FirefoxDriver();
to this instead:
new RemoteWebDriver( "http://hubIP:4444/wd/hub", capabilities );
, or something similar.
Thats it.
The correct answer is, "no, Selenium Server v2 does not support Selenium IDE output nor Selenium Builder output".
If you want to use the output of Selenium IDE browser plugin you need the incredible Selenese Runner project.
https://github.com/vmi/selenese-runner-java
Why this requires a 3rd party tool and isn't part of the Selenium family of products is beyond me.

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.

Trying to use Selenium RC

I'm pretty newbie to selenium.
Im trying to configure selenium for a project in my university like the one configured with phppgadmin.
There is no .jar file, I dont need to run anything, dont even need to install libraries, etc... I dont know if this is a RC Server or Webdriver.
Also, I want to use the PHPUnit format, cause this way I can just export test cases from the Firefox Selenium IDE plugin. There is a way to do that?
There is a lot of information, webdrivers, etc in Internet but I believe the way phppgadmin do this is the best way.
If you're just looking for something quick and dirty Selenium 1 imported off of the IDE is probably for you. If in the future you plan on continuing your university project I would highly recommend learning about Selenium Webdriver (Selenium 2).
Just as a small aside: You can export your tests from the selenium IDE in any language you desire, PHP is just one of the many choices that include (Java (JUnit), Java (TestNG), Ruby, and Python). If you're interested in PHPUnit look here http://www.phpunit.de/manual/3.1/en/selenium.html, this will give you the back drop on how to start coding your Selenium Tests.
If you're going to be using the selenium RC you want to go to http://seleniumhq.org/download/. Download Selenium server. You start the server with a java -jar command. So java -jar /path/to/sel/selenium-server-standalone-2.24.1.jar. This will start the RC server and when you're interested in running some tests execute the tests and then selenium server will take care of the rest