Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.ucll.demo.service;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.Statement;
- import java.util.Properties;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import cucumber.api.java.After;
- import cucumber.api.java.Before;
- import cucumber.api.java.en.Given;
- import cucumber.api.java.en.Then;
- import cucumber.api.java.en.When;
- import junit.framework.Assert;
- public class SmokeDetailsSteps {
- private WebDriver driver;
- @Before
- public void setUp() {
- driver = new FirefoxDriver();
- }
- @After
- public void tearDown() {
- Properties properties = new Properties();
- String url = "jdbc:postgresql://gegevensbanken.khleuven.be:51617/lector";
- properties.setProperty("user", "u0082726");
- properties.setProperty("password", "mySecret");
- properties.setProperty("ssl", "true");
- properties.setProperty("sslfactory", "org.pastgresql.ssl.NonValidatingFactory");
- Connection connection;
- try {
- connection = DriverManager.getConnection(url, properties);
- Statement statement = connection.createStatement();
- String sql ="DELETE FROM u0082726.users WHERE userid = Jakke ";
- statement.execute(sql);
- } catch (Exception e) {
- e.printStackTrace();
- }
- driver.close();
- }
- private void fillOutField(String id, String keys) {
- WebElement field = driver.findElement(By.id(id));
- field.sendKeys(keys);
- }
- @Given("^I am registered with userid Jakke and password TopSecret$")
- public void i_am_registered_with_userid_Jakke_and_password_TopSecret() throws Throwable {
- driver.get("http://java.cyclone2.khleuven.be:38034/shop-web-demo/Controller?action=signUp");
- fillOutField("userid", "Jakke");
- fillOutField("firstName", "Jakke");
- fillOutField("lastName", "Fictie");
- fillOutField("email", "Jakke.Fictie@fictie.com");
- fillOutField("password", "TopSecret");
- WebElement button = driver.findElement(By.id("signUp"));
- button.click();
- }
- @When("^I log in with my username and password$")
- public void i_log_in_with_my_username_and_password() throws Throwable {
- driver.get("http://java.cyclone2.khleuven.be:38034/shop-web-demo/Controller?action=signUp");
- fillOutField("userId", "Jakke");
- fillOutField("password", "TopSecret");
- WebElement button = driver.findElement(By.id("logIn"));
- button.click();
- }
- @Then("^I am redirected to the welcome page$")
- public void i_am_redirected_to_the_welcome_page() throws Throwable {
- boolean currentpage = driver.findElement(By.cssSelector("p")).getText().equals("Welcome Jakke!");
- Assert.assertTrue(currentpage);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement