Skip to content

Instantly share code, notes, and snippets.

@telagraphic
Created February 16, 2013 04:27
Show Gist options
  • Save telagraphic/4965543 to your computer and use it in GitHub Desktop.
Save telagraphic/4965543 to your computer and use it in GitHub Desktop.
package com.gfs.corp.bid.cucumber.pageobjects;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import com.gfs.corp.bid.cucumber.Page;
public class PageFooterPartial extends Page{
public PageFooterPartial(WebDriver webDriver) {
this.webDriver = webDriver;
}
//private WebElement pageFooter = webDriver.findElement(By.cssSelector("div#bid-footer"));
public String getFooterDate() {
String pageFooter = webDriver.findElement(By.cssSelector("div#bid-footer")).getText();
return pageFooter;
}
public String getCurrentDate(){
Date currentDate = new Date();
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
String strCurrDate = dateFormat.format(currentDate);
String todaysDate = "Todays Date: " + strCurrDate;
return todaysDate;
}
}
package com.gfs.corp.bid.cucumber.codebidspage;
import static org.junit.Assert.assertEquals;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.openqa.selenium.internal.seleniumemulation.WaitForPageToLoad;
import com.gfs.corp.bid.cucumber.pageobjects.CodeBidsPage;
import com.gfs.corp.bid.cucumber.pageobjects.PageFooterPartial;
import com.gfs.corp.bid.cucumber.pageobjects.PageHeaderPartial;
import com.gfs.corp.bid.cucumber.pageobjects.ViewBidsPage;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import cucumber.runtime.PendingException;
/**
* Feature: Code Bid page has standard page header and footer
* https://jira.gfs.com/jira/browse/SBA-2880
**/
public class StandardHeaderAndFooterStepDefs {
private ViewBidsPage viewBidsPage;
private PageHeaderPartial pageHeaderPartial;
private PageFooterPartial pageFooterPartial;
@Before
public void before_examples() throws Exception {
viewBidsPage = new ViewBidsPage();
pageHeaderPartial = new PageHeaderPartial(viewBidsPage.webDriver()); // current approach
pageFooterPartial = new PageFooterPartial(viewBidsPage.webDriver());
}
@Given("^I'm \"([^\"]*)\" user and any \"([^\"]*)\"$")
public void I_m_user_and_any(String arg1, String arg2) throws Throwable {
viewBidsPage.open();
}
@When("^I click on the \"([^\"]*)\" bid milestone tab$")
public void I_click_on_the_bid_milestone_tab(String milestoneTab) throws Throwable {
viewBidsPage.waitForPageToLoad();
viewBidsPage.clickOnMilestoneTab(milestoneTab);
}
@Then("^I should see the standard header and footer$")
public void I_should_see_the_standard_header_and_footer() throws Throwable {
assertEquals("Strategic Bid Application", pageHeaderPartial.getHeaderTitle().getText());
assertEquals("View Bids - Code", pageHeaderPartial.getCurrentPageTitle().getText());
assertEquals(true, pageFooterPartial.getFooterDate());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment