Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.database;
- import java.util.concurrent.TimeUnit;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import org.openqa.selenium.remote.DesiredCapabilities;
- public class EntryPoint {
- WebDriver driver;
- @Before
- public void setup() {
- System.setProperty("webdriver.gecko.driver","C:\\Users\\erdog\\Desktop\\Java Class\\SeleniumDrivers\\geckodriver.exe");
- DesiredCapabilities capabilities=DesiredCapabilities.firefox();
- capabilities.setCapability("marionette", true);
- driver = new FirefoxDriver(capabilities);
- driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS );
- }
- @Test
- public void loginAsEmployee(){
- DiceLogin dlogin = new DiceLogin(driver);
- //Clicking the Login/Register dropdown
- dlogin.clickLoginRegister();
- //Entering the Username
- dlogin.enterUsername("text");
- //Entering the Password
- dlogin.enterPassword("text");
- //Clicking the Login button
- dlogin.clickLoginButton();
- }
- @After
- public void close(){
- driver.close();
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------------
- package com.database;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.support.FindBy;
- import org.openqa.selenium.support.How;
- import org.openqa.selenium.support.PageFactory;
- public class DiceLogin {
- WebDriver driver;
- private static String baseUrl = "http://www.dice.com/";
- @FindBy(how = How.ID, using="Login_1")
- WebElement loginRegister;
- @FindBy(how=How.ID, using="Email_1")
- WebElement loginTextField;
- @FindBy(how=How.ID, using ="Password_1")
- WebElement passwordTextField;
- @FindBy(how=How.ID, using ="LoginBtn_1")
- WebElement loginButton;
- public DiceLogin(WebDriver driver){
- this.driver = driver;
- driver.get(baseUrl);
- PageFactory.initElements(driver, this);
- }
- public void clickLoginRegister(){
- loginRegister.click();
- }
- public void enterUsername(String text){
- loginTextField.sendKeys(text);
- }
- public void enterPassword(String text){
- passwordTextField.sendKeys(text);
- }
- public void clickLoginButton(){
- loginButton.click();
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------------
- package com.database;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class dbexample {
- public dbexample () throws Exception {
- Connection connection=null;
- Statement statement = null;
- try
- {
- // Register the JDBS driver
- Class.forName("com.mysql.jdbc.Driver");
- System.out.println("Database is registered");
- //Opening Database connection
- connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/dicetest", "root", "mirchi89");
- String sql = "select * from users";
- statement = connection.createStatement();
- ResultSet rs = statement.executeQuery(sql);
- while(rs.next()){
- String studentname = rs.getString("email");
- System.out.println(studentname);
- }
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- finally {
- connection.close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement