This is an initial list of FAQs that have been collected for Selenium Core. We encourage people to add to this list and continue feedback on the items listed below.
- What is Selenium for?
- Why can't I get Selenium Core tests to work with Google?
- How can I run my test against a foreign or remote server and get around cross-site scripting security?
- Why do I get a "Permission Denied" error when accessing my website via HTTPS?
- I can't seem to use Selenium Core to upload a file; when I try to type in the file upload text field, nothing happens!
- How do I use Selenium to login to sites that require HTTP basic authentication (where the browser makes a modal dialog asking for credentials)?
- I don't have access to the server where my AUT (application under test) is deployed, does that matter? IE., is physical deployment of app server and testrunner an issue?
- Selenium isn't working, where are the diagnostics for problem solving?
- Selenium scripts are rather verbose - Is it possible to record these scripts to speed things up?
- Is it possible to run a Selenium test without using a real browser?
- Is it possible to use Selenium for multi-user load testing?
- How to do it with Selenium
- What you can't do with Selenium
It is used for functional or system testing web applications. These tests are also sometimes called acceptance, customer, or integration tests. Selenium is not meant for unit testing.
I was trying to write a simple script that does a google search; I get a "Permission Denied" error. Here is my test:
In other words, you can't run selenium on "foo.com" and run a test that edits values and clicks buttons against "bar.com". So, in its current form, you can't "script" google.com because your script isn't currently hosted on google.com. When Selenium and the application you are testing is hosted on the same domain, however, you do not run into the cross-site scripting security feature/limitation.
You can read more about cross-site scripting here: Dev Articles
How can I run my test against a foreign or remote server and get around cross-site scripting security?
There are a few ways around cross-site scripting:
- If possible, deploy Selenium Core, and your tests, on the same web site as the application you're testing.
- You may need to use Selenium IDE or Selenium Remote Control to run your tests. See Which Selenium Tool Should I Use?
Selenium IDE is a Firefox extension, (it runs as a "chrome" url) and is therefore not subject to browser security restrictions. Selenium Remote Control provides a client-configured proxy to trick the browser into the thinking the application and the testing tool are coming from the same domain.
- IE Only: Run Selenium as an "HTA" application, or "HTML Application" in Internet Explorer. HTA applications run in the security context of any trusted application on the client, so there is no cross-site scripting limitation. (You can find out more here: MSDN
- Safari Only: Just run Selenium Core directly off of your hard disk as a "file://" URL. HTML files run off the file system aren't restricted by the same-origin policy in Safari 3.x on Mac/Windows.
This is actually the same problem as scripting a foreign web-site, described above. "http://mydomain.com" is not the "same origin" as "https://mydomain.com"; using Selenium Core, you can test HTTP or HTTPS, but not both. If you need to test both during a single test, you need to use one of the strategies listed above to test a foreign website.
I can't seem to use Selenium Core to upload a file; when I try to type in the file upload text field, nothing happens!
How do I use Selenium to login to sites that require HTTP basic authentication (where the browser makes a modal dialog asking for credentials)?
Use a username and password in the URL, as described in RFC 1738:
Note that on Internet Explorer this won't work, since Microsoft has disabled usernames/passwords in URLs in IE. However, you can add that functionality back in by modifying your registry, as described in the linked KB article. Set an "iexplore.exe" DWORD to 0 in HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE.
If you don't want to modify the registry yourself, you can always just use Selenium Remote Control, which automatically sets that that registry key for you as of version 0.9.2.
I don't have access to the server where my AUT (application under test) is deployed, does that matter? IE., is physical deployment of app server and testrunner an issue?
Physical deployment doesn't strictly matter, but if you can't modify your AUT, you do have to somehow either force the browser to disable the same-origin policy or trick the browser into thinking that your tests and your AUT have the same origin.
Yes, but it requires a LOT of hardware. We recommend you check out BrowserMob, which does load testing with real browsers and is powered by Selenium.
In Selenium, you work with one window at a time. To work with a different window, for example one that has popped up as a result of clicking a link, you need to first select that window. In order to select it, you must somehow identify it. Various identification methods can be used (see documentation on the selectWindow command at http://selenium-core.openqa.org/reference.html); the easiest may be for you to capture the id by recording the popup creation with the Selenium IDE. Something like the following will be recorded:
You probably want to wait for the popup to load before you start interacting with it. Also, when you're done with it, you'll probably want to close it, and reselect the original window. A simple idiom to follow would then be:
Currently it is only possible to do this by configuring Firefox with a profile template, telling it to save a file to a specified location without prompting the user with a file chooser dialog. See here: http://clearspace.openqa.org/message/31350 . There do not appear to be workarounds for other browsers yet.
To solve this issue, you may use a workaround (if one exists); otherwise you may have to exclude the test from your automated corpus. For the "Save File" dialog in Firefox, a custom template may be specified when running via the RC that will always cause the file to be downloaded to a specified location, without querying the user (see http://forums.openqa.org/thread.jspa?messageID=31350). The "Remember this Password" dialog should not appear again after you've chosen to remember it. Currently there is not much that can be done about IE modal dialogs.