0

I am able to get particular column value form the Oracle Database and populate that value in the particular field on the Web Page as below. However, I am not bale to figure it out how can I get particular cell value from Oracle Database Table and populate that value in the particular field on Web Page.

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.testng.Assert;
import org.testng.annotations.Test;

public class ProApp extends BaseClass {

    @Test(priority = 2)
    public void setUpConnection() throws ClassNotFoundException, SQLException, FileNotFoundException, InterruptedException, IOException {
        String driver_DBPath = "jdbc:oracle:thin:@Host:Port:SID";
        String DB_username = "*****";
        String DB_password = "*****";
        String Query = "select * from TestTable";

        Connection con = DriverManager.getConnection(driver_DBPath, DB_username, DB_password);
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(Query);

        while (rs.next()) {
            String Email = rs.getString("CLAIM_NUMBER");
            String Pwd = rs.getString("INDIVIDUAL_NUM");
            testUserNamePassword(Email, Pwd);
        }
    }

    @Test(priority = 1)
    public void clickLoginLink() throws InterruptedException, IOException {
        Properties obj = new Properties();
        FileInputStream objfile = new FileInputStream(System.getProperty("user.dir") + "\\src\\com\\provider\\Object.Properties");
        obj.load(objfile);
        driver.findElement(By.xpath(obj.getProperty("ClickOnLoginLink"))).click();
        Thread.sleep(1000);
    }

    @Test(priority = 3)
    public void testUserNamePassword(String Email1, String Pwd1) throws InterruptedException, IOException {
        Properties obj = new Properties();
        FileInputStream objfile = new FileInputStream(System.getProperty("user.dir") + "\\src\\com\\provider\\Object.Properties");
        obj.load(objfile);
        Thread.sleep(1000);
        driver.findElement(By.xpath(obj.getProperty("Email1"))).clear();
        Thread.sleep(1000);
        driver.findElement(By.xpath(obj.getProperty("Email1"))).sendKeys(Email1);
        Thread.sleep(1000);
        driver.findElement(By.xpath(obj.getProperty("Pwd1"))).clear();
        Thread.sleep(1000);
        driver.findElement(By.xpath(obj.getProperty("Pwd1"))).sendKeys(Pwd1);
        Thread.sleep(1000);
        driver.findElement(By.xpath(obj.getProperty("Submit"))).click();
        Thread.sleep(1000);
    }
}
Curious
  • 282
  • 4
  • 21
  • particular cell value from oracle means? trying to get particular value by sql? can you provide some more info on this – murali selenium Mar 30 '16 at 16:27
  • Particular cell value means For example CLAIM_NUMBER column store value 1234567890, 1234567891, 1234567892, 1234567893 So now from CLAIM_NUMBER column I want only value 1234567892 which is sitting in row three and populate only value 1234567892 in the field on the web page. – Curious Mar 30 '16 at 16:41
  • if you want to get third row then use appropriate sql query. this may helps http://stackoverflow.com/questions/4509167/select-nth-row-from-a-table-in-oracle – murali selenium Mar 30 '16 at 16:52

0 Answers0