Skip to main content

Posts

Showing posts from April, 2014

JDBC Program to connect data base

package Specific path; import java.sql.DriverManager; import java.sql.Connection; import java.sql.SQLException; public class Jdbcprogram { public static Connection connection = null; public static Connection getConnection() { System.out.println("-------- PostgreSQL "+ "JDBC Connection Testing -----------"); try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException e) { System.out.println("Where is your PostgreSQL JDBC Driver? " + "Include in your library path!"); e.printStackTrace(); } System.out.println("PostgreSQL JDBC Driver Registered!"); try { connection = DriverManager.getConnection( "Data base Url", "user name", "password"); } catch (SQLException e) { System.out.println("Connection Failed! Check output console"); e.printStackTrace(); } if (connection != null) { System.out.println("You made it, take control your database now!"); } e

Wait for an element

Wait for an element try { WebDriverWait wait = new WebDriverWait(driver, 20); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("XXXXXXXXX")))); System.out.println(object + " : element found"); return Constants.KEYWORD_PASS; } catch (Exception e) { System.err.println(object + " : element not found"); }

Double Click using selenium

This following sample code used for the double click operation. WebElement oWE = driver.findElement(By.xpath("XXXXXXXX")); if (oWE.isDisplayed()) { System.out.println("Displayed"); Thread.sleep(4000); Actions oAction = new Actions(driver); oAction.moveToElement(oWE); oAction.doubleClick(oWE).build().perform(); Thread.sleep(4000); oWE.click(); }