-
Notifications
You must be signed in to change notification settings - Fork 22
Selenium
⚠️ This page is stale and is kept for reference only. For current testing docs, see Testing.
Selenium is a testing framework for automated testing of web applications. You can find more information about selenium here http://docs.seleniumhq.org/docs. We are using selenium with TestNG (http://testng.org), which is a testing framework inspired by JUnit. It gives us flexibility xml based configuration and automated reports. More about how to use Selenium and TestNG together can be found here http://testng.org/doc/selenium.html.
Selenium has two versions Selenium 2 (WebDriver) and Selenium 1 (RemoteControl). We are using Selenium 2 but still using the old framework i.e Remote Control because the new version not yet support some of the functionality. For running Selenium Remote Control, a selenium host should be started that listens to clients (browsers) which runs the test cases. In our setup all of this is configured in the BaseTestCase java class.
There are two configuration files: testng.xml and local.conf.
It contains the configuration and sequence of test cases to run. It also contains the following three important parameters that needs to be configured to run Selenium.
<parameter name="selenium.host" value="localhost" />
<parameter name="selenium.port" value="8123" />
<parameter name="selenium.browser" value="*firefox" />
The selenium will use the host and port parameters to start a listener and use the browser parameter to load a browser that will run the test cases.
Note that each test in testng.xml will load a new browser session.
In local.conf define the following properties
homeURL = /xmlui
browseURL = /xmlui/browse
searchURL = /xmlui/discover
submissionURL = /xmlui/submissions
submitURL = /xmlui/submit
localLogin = /xmlui/password-login
UserID =
Password =
UserName =
adminUserID =
adminPassword =
adminUserName =
new users can be defined using a prefix with UserID, Password, and UserName properties e.g. an admin user is defined above. The user can be passed as a parameter to a test case in testng.xml. see the example below:
<test name="Test Item Submission with Admin" preserve-order="true">
<parameter name="user" value="admin" />
<classes>
<class name="cz.cuni.mff.ufal.test.LoginTest">
<methods>
<include name="testLoginLocal" />
</methods>
</class>
<class name="cz.cuni.mff.ufal.test.SubmissionTest">
<methods>
<include name="testSubmissionWithAdmin" />
</methods>
</class>
</classes>
</test>
Create a new Java class and extends it with cz.cuni.mff.ufal.test.BaseTestCase. Create a new method and write the selenium commands for the test case in it. This method can also be generated using Selenium IDE plugin for firefox see http://docs.seleniumhq.org/docs/02_selenium_ide.jsp for details. We need to export the Selenium IDE test case to “Java / TestNG / Remote Control”
When using Selenium IDE to generate the code, only copy the code inside the method to the method you created and change all the assertion methods to org.testng.AssertJUnit methods. Selenium IDE is using a different wrapper class SeleneseTestNgHelper but that is not working properly with Remote Control.
Following is a sample test case for testing the UFAL Point home page.
public class HomePageTest extends BaseTestCase {
@Test
public void testHomePageLoad() {
selenium.open(prop.getProperty("homeURL"));
selenium.waitForPageToLoad("30000");
AssertJUnit.assertEquals(selenium.getTitle(), "Home");
}
}
Add the new Test to testng.xml.
<suite name="UFAL Point Test Setup" verbose="10">
<test name="Test Home Page Loading" preserve-order="true">
<classes>
<class name="cz.cuni.mff.ufal.test.HomePageTest">
<methods>
<include name="testHomePageLoad" />
</methods>
</class>
</test>
</suite>
From command line, the testng.xml can be run with ant using the “testng” ant task. see the build.xml file.
see http://www.alittlemadness.com/2008/03/05/running-selenium-headless
In our makefile scripts there is a target “selenium_tests” that will run all the tests in testng.xml without opening a browser.
Getting Started
Features
- All Features — full categorised list
- CLARIN Licenses
- PIDs & Handles
- Featured Services / Refbox
- Field-Level Permissions
- File Previews
- Sharing a Submission
- Personal Access Tokens
- DOI Configuration per Community
- ROR Authority
Operations
- Kubernetes Deployment
- Samples (.env, Nginx)
- Nginx + Shibboleth
- Handle Server · Setup (v7)
- Shibboleth · DiscoJuice
- Shibboleth Accounts
- S3 Storage · CESNET S3
- Google Analytics
- Matomo
- Solr
- Logging
- Custom Namespace
- Health Report
For Users
Development
Reference
- Authorizations
- Metadata Info
- Citations (proposal)
- Repository Checklist
- Search, Browse & Filters
- Localization
- Importing Items (CLI)
- NFA Import - Steps
- OpenAIRE
- DOI Registration
- Inclusion in OLAC
- Unit Testing
- Deploy Checks
- Troubleshooting
- Versioning Theory
- Dynamic Resource Versioning
- Metashare Import · Schema
- Web Server Overview
- LINDAT Common Theme
- Workshop 2016 Results
- WebLicht Integration
- Google Dataset Search
Archive (v5 / stale)
- Old Home (v5)
- Installation (v5)
- Prerequisites (v5)
- Connecting Tomcat with Apache
- Using Apache
- Building Shibboleth FastCGI
- Shibboleth Install (v5)
- EUDAT Replication
- Backup (v5)
- Spring Social / Google Drive (v5)
- Clarin (→ Repository Checklist)
- Control Panel (v5)
- Overlays (v5)
- Configuration (v5)
- Speeding Up Downloads
- Debugging (v5)
- Selenium (v5)
- Code Contributions (v5)
- Best Practices (v5)
- Testing Hudson
- Working on Windows
- Prerequisites Checklist (v5)
- Migration to DSpace 7.2.1
- Upgrade From Lindat
- Piwik (→ Matomo) · Piwik Cleaning