Running Selenium test suite with browser minimized - selenium-rc

As part of our web application deployment I need to do basic smoke test after the deployment.
I am using Selenium RC to run the smoke test automatically at the end of the deployment.
now How can I run the browser minimized (not poping up) while running the test suite.
Below is the command used to run the test suite
java -jar D:\Selenium\RC\selenium-server-standalone-2.25.0.jar -htmlSuite *firefox https://abc.com C:\Users\abc\Desktop\testsuite.html results.html -firefoxProfileTemplate C:\Users\331036\AppData\Roaming\Mozilla\Firefox\profiles\imvteil2.selenium

I have an alternate solution that may meet your needs. You can set the position of the WebDriver to be outside of your view. That way, it'll be out of sight while it runs. (It may start at a visible location, but it will only be there for an instant.)
FirefoxDriver driver = new FirefoxDriver();
driver.manage().window().setPosition(new Point(-2000, 0));

I don't think that this is possible, The Browser will pop up , you will have to minimize it manually

Related

Cucumber reporting and browser hiding

I'm using cucumber (ruby) + watir for running behavior driven tests, and I'm trying to do a couple of things for integrating it with Hudson CI:
Currently, the browser window pops up on the build slave each time the job runs. Is there a way to hide the browser window while the tests run?
I am using the jUnit formatter and having Hudson parse the test results. However, I'd like to print a test summary with the feature/scenario names and the test result (pass/fail) on the console window so that the email notification sent out lists the test summary. How do I do that?
Currently, cucumber prints a lot of debug output including deprecated function warnings. The -q flag doesn't seem to do anything for me. Is there a way I can stop cucumber from printing anything on the screen?
Edit: I'm running the tests on a Windows 7 desktop.

In the play framework, how do I run just one selenium test suite and have it run automatically?

I am doing Test Driven Development using the Play Framework and want to keep run the current failing test quickly. I am finding clicking Start! to be to slow since I have a mostly keyboard driven workflow. So ideally I would like a way to just reload the page and have it rerun the currently failing test.
I ended up leaving play test running and reloading the following page - note the auto=yes parameter
http://localhost:9000/#tests?select=Application.test.html&auto=yes

Selenium store result of web service/AJAX call

Is it possible to store the result of a web service/AJAX call into the store element, so that its value can be used in multiple locations.
The reason for this is we would like to have an automated test suite that uses data defined in a database. This would make it much easier to change bulk data in the tests (instead of searching through all of our test cases to change the data).
I understand that we can create a test case at the beginning of our test suite that defines all of this data however, we would like to easily switch between data sets without having to re-type each value.
I'm not sure how you can do what you're asking. It would be cool to learn. But let me give you a different approach which is very easy. I can answer any questions you may have. Create 3 different commands in your Selenium IDE to start things off, where your target for the open command is the path of the page you're automating.
Command: open
Target: --path--
Value:
Command: storeExpression
Target: 123
Value: var_number
Command: type
Target: TextBox1
Value: ${var_number}
Then use the export option in Selenium IDE as Java code (or another language). You won't have the Options > Format > options unless you turn on "Enable Experimental Features" in options. Choose "JUnit 4 (Remote Control or RC)"--Selenium 1. I'm not familiar with "JUnit 4 (WebDriver)"--Selenium 2 yet, but it's a bit newer, and not as much documentation. Then download Eclipse Classic, the Java JDK, the Selenium client driver for Java (on the Selenium site)--dll #1, and download JUnit 4--dll #2. Import both of those dll files into the Library tab (in Eclipse classic) after creating a new project in the project wizard, and open your export code that was exported using the Selenium IDE format export. Eclipse should be configured to automatically compile your code by default. Then just create an loop in the Java code and repeat the commands above. Then connect to your database from Java (with some simple SQL connection code), and read your data from the result set inside of your loop. Then right click in the Eclipse file explorer and choose JUnit on your unit test to launch a Mozilla Firefox instance to have it automate your loop. Or you can launch any other browser to run your JUnit test.. just change "*chrome" (aka Mozilla not Google Chrome) to "*iexplore" (Internet Explorer) or "*googlechrome" (Google Chrome), etc... for a browser of your choice in the Java code.
Pardon my jargon on "dll files". I meant to write assemblies or libraries. In Java, the correct term would be a *.jar. I'm use to writing in .NET code. If you choose to run your unit tests in .NET, then you will need to repeat most of what I have above, but instead download NUnit and use Visual Studio rather than Eclipse. The documentation is much better for JUnit, so that's why I went that route. That statement might not be correct. That's just what I found to be true from observation when I did a proof of concept for my company.
Oh, and because you're using client drivers, you need to have the Java (JUnit Test) program connect to your Selenium Remote Control Server. So you must download the Selenium server also. Then call the Jar from the command line in Windows. It must be running before running your JUnit test. This server won't run unless the JDK is installed on your machine!
java -jar selenium-server-standalone-2.0rc3.jar
The contributed user extension: http://wiki.openqa.org/display/SEL/global makes use of the global array globalStoredVars which you should be able to use.
I started recently to test a multilanguage website using Selenium with javascript, see Testing-a multilanguage website with selenium

Problem about running php test suite and test case using Selenium RC

I need a php test case and how can i test a php test case using selenium RC. Already i have set up Selenium RC in my computer.Not only that, i need a test suite. What is the purpose of test suite and test case? Is the test suite and test case same thing?
It would be very helpful helpful for me if any one post a solution in the blog as early as possible.
The Recorded test scripts can be than exported to PHP language and with the help of these you can create a library which contains all the functions/tests which has to be performed on the application
Now create the suites for different libraries which will call the functions in the libraries and executes it on application.
Start the Selenium RC using the command “java –jar selenium-server. jar”
On the new command prompt enter the specific directory location of the file and enter “phpunit xyz.php”
Selenium is a tools that let you automate visits to a site and test for conditions; mostly presense of text on page or in html controls. The selenium server needs to be running which will enable you to control a browser (firefox by default) to do you automation tasks.
Starting the server could be something like
"javaw.exe" -jar selenium-server-standalone-2.0b2.jar"
where javaw.exe is part of your java runtime, most likely in C:\Program Files (x86)\Java\jre6\bin\ or C:\Program Files\Java\jre6\bin\.
You also have the possibility of installing a Selenium IDE as a plugin to firefox which lets you record, edit and playback tests.
The most likely usage would though be to implement tests in a test runner like nunit or a php program. The IDE has export functionality for this.

Is there a way to freeeze Selenium-RC execution on error?

My Google-fu is weak and so I turn to the hive mind...
I have a Selenium script I originally developed in the IDE, which I am now trying to adapt to run on IE8 via Selenium-RC. I'm trying to debug an error where an element is not being found.
The problem is that as soon as the error occurs, the script exits and RC closes the browser. This makes it a bit hard to poke around with Firebug, etc, to see what is going on under the covers.
In the IDE, I could simply set a breakpoint. Is there a way to freeze the state of RC and the browser when an error occurs?
Any other ideas?
Thanks!
Depending on how you're running your RC tests, you could set a breakpoint in your IDE and run the test in debug mode. For example I use Eclipse to run tests using Java. Another option is to put a long pause in your test, just make sure you remove it again afterwards..!
I am running selenium rc tests as part of my test suite, so I just fire up --pdb (in python) and script pauses when exception occurs - before tearDown that closes the browser is invoked.
I have also had a plugin where I took a screenshot when something went wrong.
If you are using JUnit and SeleniumTestCase, you can add an empty tear down method to your test code which should prevent the browser from shutting down by overriding the base SeleniumTestCase tear down method. I use this on failing tests which I need to examine the resulting browser state after a failure.
In these situations I comment out the selenium.close() and selenium.stop() commands in my code which stops the browser from closing.
IIRC screenshot is only supported for firefox, so that won't help in your case.

Resources