I'm trying to run an HTML testSuite with Selenium RC. The browser starts, the first test runs, and it stops. It doesn't continue to the second test case. I named both the test cases with .html extension. I am using Firefox.
If I run them manually, individually from the selenium RC test runner window they run ok. What am I missing, this seems pretty simple but yet I'm not able to get this working.
I am using Selenium RC 1.0.3
java -jar selenium-server.jar
-firefoxProfileTemplate"C:\Users\sicky\AppData\Roaming\Mozilla\Firefox\Profiles\zvt0jj7c.default"
-htmlsuite "*firefox" "https://4.17.8.9/" "C:\Users\sicky\Documents\selenium scripts\suite.html"
"C:\Users\sicky\Documents\selenium scripts\results.html"
What am I missing?
ok I figured this out. What I was doing was , I was converting the existing scripts into HTML. Apparently it doesnt work that way. It looks like I have to name them with html extension when I make those test cases itself, then the whole suite will run –
Actually I had the same behaviour and my test scripts were in fact created in Selenium IDE and had the proper .html extension.
However! The test suite itself didn't have the .html extension. I just added it and it started working properly.
Related
I have a problem with Selenium and can't get it to work.
What I want to do:
A customer of ours sends us a Selenium test case which shall be executed automatically in several locations and the time taken shall be recorded.
We want to use Selenium and Firefox Portable, because we want to make the tests completely independent of any user input and the installed software at the different locations.
So much for the starting conditions ;)
What we did so far:
The first version was completely written in Java, we exported the test case from the customer to Java with the Selenium IDE Plugin -> Export to Java WebDriver.
This cannot be done anymore, because the customer now uses some functions the WebDriver export does not support. And as we don't want to alter the test from the customer, Java export is no longer an option.
So for the first run we are using this command (any variables are set correctly):
java -jar selenium-2.33.0/selenium-server-standalone-2.33.0.jar -port 5555
-firefoxProfileTemplate "Firefox\Data\profile" -log logs\selenium_server.log
-htmlSuite "*firefox" http://localhost:5555 Testsuite.html
logs\results-firefox-%curTimestamp%.html
This starts my preinstalled firefox, not the portable one. On the customers machine, no firefox is started whatsoever, because it is not installed. So I had to provide the path to the firefox instead, using the "custom" htmlSuite:
java -jar selenium-2.33.0/selenium-server-standalone-2.33.0.jar -port 5555
-firefoxProfileTemplate "Firefox\Data\profile" -log logs\selenium_server.log
-htmlSuite "*custom %FF_DIR%\FirefoxPortable.exe" http://localhost:5555 Testsuite.html
logs\results-firefox-%curTimestamp%.html
This does not work, as the Selenium Server cannot execute this command if run under Windows, which we do (see: http://code.google.com/p/selenium/issues/detail?id=3274)
As comment #6 has some diffs, we patched the selenium Server standalone Jar and ran the test again. Now the browser could be started, but the test could not be run. After the first page loaded we get the error "Permission denied to access property 'document'".
A solution here suggests, a user-rights problem could be the cause and you should try the "chrome" htmlSuite (see: https://sqa.stackexchange.com/questions/1453/how-to-fix-permission-denied-to-access-property-document)
So we did:
java -jar selenium-2.33.0/selenium-server-standalone-2.33.0-patched.jar
-port 5555 -firefoxProfileTemplate "FirefoxPortable\Data\profile"
-log logs\selenium_server.log -htmlSuite "*chrome %FF_DIR%\FirefoxPortable.exe"
http://localhost:5555 Testsuite.html logs\results-firefox-%curTimestamp%.html
Notice our "patched" selenium and the "chrome" htmlSuite.
That didn't work, as well.
So, here in short the results:
htmlSuite = firefox: the preinstalled Firefox is used, if installed, not the Portable one. In case, no FF is installed, the test fails altogether
htmlSuite = chrome: the server cannot start the browser, as it tries to set EnvironmentVariables, which is not supported running Windows (see: http://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/os/WindowsProcessGroup.java#67 lines 67 following)
htmlSuite = googleChrome: Google Chrome Portable can be started, but the Chrome browser cannot find some elements specified by the test, so we cannot use Chrome (altering the test is no option, as stated above)
htmlSuite = iexplore: Internet Explorer starts, but then a JavaScript error appears, referencing a custom Profile created by Selenium, so the test does not work in IE, either
htmlSuite = custom: the Portable Firefox is started (yeehaw), but does not have sufficient rights to execute the test.
You may use a Continuous Integration System like Jenkins, or TeamCity to execute your tests automatically.
we have now decided to support the customer in installing Firefox on the machines to test, so we can use our batchfile without problems.
As for the bug in selenium look here (code.google.com/p/selenium/issues/detail?id=5554#c14), there is a link to a nightly build that does work (at least for us) with Firefox v23, which Selenium 2.33 does not.
Thanks for everyone who contributed, but I think my first approach can not be achieved the way I thought it could :(
I solved this problem.
Visit this link: http://www.townx.org/blog/elliot/dealing-self-signed-ssl-certificates-when-running-selenium-server-firefox
Point 9:
Delete everything in the directory except for the cert_override.txt and cert8.db files.
Hope it helps
I'm trying to run an HTML testSuite with Selenium RC. The browser starts, the first test runs, and it stops. It doesn't continue to the second test case. I named both the test cases with .html extension. I am using Firefox.
If I run them manually, individually from the selenium RC test runner window they run ok. What am I missing, this seems pretty simple but yet I'm not able to get this working.
I am using Selenium RC 1.0.3
java -jar selenium-server.jar
-firefoxProfileTemplate"C:\Users\sicky\AppData\Roaming\Mozilla\Firefox\Profiles\zvt0jj7c.default"
-htmlsuite "*firefox" "https://4.17.8.9/" "C:\Users\sicky\Documents\selenium scripts\suite.html"
"C:\Users\sicky\Documents\selenium scripts\results.html"
What am I missing?
ok I figured this out. What I was doing was , I was converting the existing scripts into HTML. Apparently it doesnt work that way. It looks like I have to name them with html extension when I make those test cases itself, then the whole suite will run –
Actually I had the same behaviour and my test scripts were in fact created in Selenium IDE and had the proper .html extension.
However! The test suite itself didn't have the .html extension. I just added it and it started working properly.
Currently I am working on selenium IDE, now I need to switch to selenium RC. I have downloaded selenium server.But I really don't know how to proceed further. Even I am not able to start server from command prompt. I have used C:\Selenium RC\selenium-server\jave -jar selenium-server.jar, but it struck in between and not proceeding further..
I am looking for language java or PHP.
Let me know how should I move further for successful execution of scripts by using selenium RC
First of all: save a test suite in Selenium IDE (File > Save Test Suite). You should generate test suite - it will contain information about test cases (which, of course, should also be saved (File > Save Test Case)).
Then you are ready for testing with Selenium RC.
Try it with below command:
java -jar path/to/selenium-server-standalone.jar -htmlsuite "*firefox" "http://google.com" "path/to/your/testsuite1" "path/to/result.html"
result.html - this file will be generated during/after execution.
Be sure that name of browser, URL and paths to test suite and result file are in the quotation marks.
I am using Selenium with PHPUnit. I have got class called, lets say, somethingTest (test classes must have 'Test' at the end of their names) and extended PHPUnit_Extensions_SeleniumTestCase. This class contains several test cases as methods (e.g. function testSomeMethod1() - 'test' at the beginning).
And I run it by command:
phpunit somethingTest.php
As to the second thing:
Unknown command: gotoIf
You should load gotoif extension by adding to the execution command something like: -userExtensions path/to/extension-file
This indicates a JavaScript file that will be loaded into Selenium.
If you choose Java to write code, a better approach would be using an IDE like Eclipse. Once you link the JARs and import them in your Java classes you can write your code quickly and efficiently. On top of that, Ecplise has lot of plugins for testing software like Junit, TestNG's to help you create better test suites. Not to mention a Java IDE is always helpful in debugging test code. Here is a tutorial on how to setup Eclipse with Selenium: http://selftechy.com/2011/05/31/setting-up-selenium-with-eclipse
Hope it helps.
Is there a way to invoke the Selenium IDE From the Linux command line. I would really like to have a command that when run would cause the Selenium IDE to run the current test. (This way I can hook it into gvim's save hook and never take my hands off the keyboard)
EDIT:
I know how to get PHP unit or the like to run selenium. That works great for running tests, the problem is that right now what I am trying to do is use the selenium IDE as a macro. IE to load my app and navigate me to the part I am working on. That does not work well from phpunit because it reloads the page as soon as the test ends.
You cannot run IDE directly from the command line, however you can use Selenium RC to run scripts recorded in Selenese (i.e. recorded by Selenium IDE) without converting them to a different language.
Run Selenese Directly Within the
Server Using -htmlSuite
You can run Selenese html files
directly within the Selenium Server by
passing the html file to the server’s
command line. For instance:
java -jar selenium-server.jar
-htmlSuite "*firefox" "http://www.google.com"
"c:\absolute\path\to\my\HTMLSuite.html"
"c:\absolute\path\to\my\results.html"
This will automatically launch your
HTML suite, run all the tests and save
a nice HTML report with the results.
Note
When using this option, the server
will start the tests and wait for a
specified number of seconds for the
test to complete; if the test doesn’t
complete within that amount of time,
the command will exit with a non-zero
exit code and no results file will be
generated.
This command line is very long so be
careful when you type it. Note this
requires you to pass in an HTML
Selenese suite, not a single test.
Also be aware the -htmlSuite option is
incompatible with -interactive You
cannot run both at the same time.
The above is taken from http://seleniumhq.org/docs/05_selenium_rc.html
What I found you can do is use the unix command line tool "xdotool" to generate the click event on the button, which will run the script. Exactly what I wanted to do. This is the command line I run. (Its in a shell script)
xdotool search --name "Selenium IDE" mousemove --window %1 153 65 click 1
For the Selenium IDE I don't know a solution. Selenium IDE is the user frontend for the Selenium Core.
But to run a set of working test scripts, you can use Selenium Remote Control (RC). This is an API for the Selenium Core. It is available for Java, Ruby, Python, .Net/C#, Perl, PHP.
You can record a macro with Selenium IDE. Then you can export the macro to each of the supported programming languages. I used it successfully for Java:
Exported the script to Java
Wrapped the Java code with a JUnit test case
Used a simple main method in a Java class to parse some command line arguments and to call the JUnit runner
Started the Selenium Server from the command line
Called the Java class from the command line
It should work in an analogous way for other programming languages. Compile Java or C# to an executable or directly call the Python/Ruby/Perl script.
The wrapping as a JUnit test case is optional. The advantage is that you can execute the Selenium macro also with any other JUnit runner, e.g. in Eclipse or with the JUnit Ant task.
I have a set of tests that I've developed using the Selenium IDE in Firefox. Tests run fine and all pass. Now I'm trying to port those over to C# and run the tests for IE using MSTest and selenium-server. Here's the sequence of events:
Run all tests on Firefox via Selenium IDE. All tests pass.
Export tests to MSTest (Nunit export, rename some stuff etc.)
Start selenium-server-1.0.3
Run the tests in VS2008. Selenium setup is: selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost/theSite/");; note that I can browse to http://localhost/theSite/ just fine.
4a. Confirm test is launching Firefox. Got result:
17:00:30.290 INFO - Preparing Firefox profile...
17:00:33.842 INFO - Launching Firefox...
First test ( waitForText "Login" in control "ctl00_TopNavBar_LoginStatus1") fails. Can't find the control.
if ("Login" == selenium.GetText("id=ctl00_TopNavBar_LoginStatus1")) break;
or
if ("Login" == selenium.GetText("ctl00_TopNavBar_LoginStatus1")) break;
All other tests fail as well -- same reason. Each test has a waitForText at the top.
Tried running the test in *chrome, *iexploreproxy and *firefox. All fail for the same reason.
Tried dumping a screenshot using selenium.CaptureEntirePageScreenshot("c:\\temp\\screenshots\\seleniumSite.png", "background=#FFFFFF"); and the screenshot is just a white bar.
So, my question is, how do I go about debugging this and figuring out what the real problem is? Clearly the page will render and the tests will pass. It's just when I try those tests in Selenium-RC that it fails so badly. Does the Selenium IDE have some bugs related to exporting tests to C#? (I have noticed one bug).
Are you executing selenium.Start() and selenium.Open()? Do you see the page opened in the browser?
Full initialization should be something similar to:
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost/");
selenium.Start();
selenium.Open("/theSite/");
Important Note! test your IDE tests by starting with an empty page. Also, when using the IDE, if a command only has one parameter put it in the Target field, even if it isn't a control name.