For similar example using Selenium v1, see Check radio buttons and checkboxes.
import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; /** * Selenium v2: Un/Check radio buttons and check boxes. * It is assumed that Firefox is installed on your computer. * @Author: Xuan Ngo */ public class CheckExample2 { public static void main(String[] args) { // All actions will be applied to Firefox. WebDriver oWebDriver = new FirefoxDriver();
For similar example using Selenium v1, see Select single/multiple options.
import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.Select; /** * Selenium v2: Select single and multiple options. * It is assumed that Firefox is installed on your computer. * @Author: Xuan Ngo */ public class SelectExample2 { public static void main(String[] args) { // Run all actions on Firefox. WebDriver oWebDriver = new FirefoxDriver(); // Open the webpage.
For similar example using Selenium v1, see Type characters.
import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; /** * Selenium v2: Type characters. * Assume that you have Firefox installed. * You need to change the encoding of your editor to support the Chinese characters below. * @Author: Xuan Ngo */ public class WritingExample2 { public static void main(String[] args) { // All actions will be applied to Firefox.
For similar example using Selenium v1, see Click on any html element using different locators.
import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; /** * Selenium v2: Click on any html element in the webpage as long as you can use the locators to identify them. * Assume that you have Internet Explorer. * @Author: Xuan Ngo */ public class ClickAnyElementExample { public static void main(String[] args) { // All actions will be applied to Internet Explorer
For similar example using Selenium v1, see Click on link.
import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; /** * Selenium v2: Click on a simple link(e.g Next) * Assume that you have Internet Explorer. * @Author: Xuan Ngo */ public class ClickExample { public static void main(String[] args) { // All actions will be applied to Internet Explorer WebDriver oWebDriver = new InternetExplorerDriver();
/** * Show the limits of primitive data types in Java. * Note: Unlike other languages(e.g. C/C++), Java doesn't provide unsigned types of its integers. * @author Xuan Ngo * */ public class LimitsOfPrimitiveDataTypes { public static void main(String[] args) { String s = ""; // Byte s = String.format("%-24s: min = %,-27d, max = %,-27d", Byte.class, Byte.MIN_VALUE, Byte.MAX_VALUE); System.out.println(s); // Short s = String.format("%-24s: min = %,-27d, max = %,-27d", Short.class, Short.MIN_VALUE, Short.MAX_VALUE);
| MySQL Data Type | Java Data Type |
|---|---|
| CHAR | String |
| VARCHAR | String |
| LONGVARCHAR | String |
| NUMERIC | java.math.BigDecimal |
| DECIMAL | java.math.BigDecimal |
| BIT | boolean |
| TINYINT | byte |
| SMALLINT |
Here is an example of how you would define a list of values in hibernate for the SQL IN() operator:
Query oQuery = session.createSQLQuery("UPDATE Person SET gender=:gender WHERE id IN(:id_list)"); oQuery.setString("gender", "male"); oQuery.setParameterList("id_list", new Object[]{new Integer(1), new Integer(21), new Integer(45)}); int iRowCnt = oQuery.executeUpdate();
org.hibernate.Query.setInteger() function doesn't allow your integer to be null whereas org.hibernate.Query.setParameter(..., ..., Hibernate.INTEGER) function allows your integer to be null.
For example, if you are parsing a file to retrieve the age of a person and then update that age into your database. However, the age is not always written in the file. Therefore, the age is nullable. Here is a code example using setParameter() function to deal with nullable integer:
//...To the perfect testing framework for web applications.
The api is located at http://webdriver.googlecode.com/svn/javadoc/index.html?overview-summary.html
http://selenium.googlecode.com/svn/trunk/docs/api/java/overview-summary.html
What are new:
-Merge the best of Selenium and Webdriver.
-Complete change of the api.
-Bundle into a standalone jar.