diff --git a/cucumberTest/build.gradle.kts b/cucumberTest/build.gradle.kts index 7fa314e..b5b2454 100644 --- a/cucumberTest/build.gradle.kts +++ b/cucumberTest/build.gradle.kts @@ -22,4 +22,15 @@ task("cucumberTodo") { args = listOf("--plugin", "pretty", "--glue", "todo", "src/test/resources/todo") } } +} + +task("cucumberiCite") { + dependsOn("assemble", "testClasses") + doLast { + javaexec { + main = "io.cucumber.core.cli.Main" + classpath = configurations.getByName("cucumberRuntime") + sourceSets.main.get().output + sourceSets.test.get().output + args = listOf("--plugin", "pretty", "--glue", "iCite", "src/test/resources/iCite") + } + } } \ No newline at end of file diff --git a/cucumberTest/src/test/java/iCite/SimpleSearch.java b/cucumberTest/src/test/java/iCite/SimpleSearch.java new file mode 100644 index 0000000..97156ea --- /dev/null +++ b/cucumberTest/src/test/java/iCite/SimpleSearch.java @@ -0,0 +1,130 @@ +package iCite; + +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; +import org.openqa.selenium.*; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; +import org.openqa.selenium.interactions.Actions; + +import java.util.concurrent.TimeUnit; + + +//SimpleSearch +public class SimpleSearch { + private WebDriver driver; + + @Given("I am on the iCite page.") + public void iAmOnTheiCitePage() { + driver = new FirefoxDriver(); + driver.get("https://icite.od.nih.gov/covid19/search/"); + //lets the application compile + driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); + } + + @When("I click my mouse in the Search query field.") + public void iClickInTheSearchQueryField() { + // driver.findElement(By.id("searchBox")).click(); + WebElement element = driver.findElement(By.id("searchBox")); + WebDriverWait wait = new WebDriverWait(driver, 20); //here, wait time is 20 seconds + wait.until(ExpectedConditions.visibilityOf(element)); //this will wait for element to be visible for 20 seconds + element.click(); //now it clicks on element + } + + @When("I enter pcsk9.") + public void ienterpcsk9() { + driver.findElement(By.id("searchBox")).sendKeys("pcsk9"); + } + + @When("I click the magnifying glass.") + public void magnifyingGlass() { + driver.findElement(By.id("searchButton")).click(); + } + + @Then("the results for pcsk9 will be displayed.") + public void theResultsWillBeDisplayed() { + driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); + } + +//Simple Search using AND function + + @When("I search for COVID and SYMPTOMS.") + public void isearchforcovidandsymptoms() { + driver.findElement(By.id("searchBox")).sendKeys("COVID and SYMPTOMS"); + } + + @Then("all results for COVID as well as SYMPTOMS will be displayed.") + public void alltheresultsforcovidaswellassymptomswillbedisplayed() { + driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); + } + +//Simple Search using OR function + + @When("I search for COVID or SYMPTOMS.") + public void isearchforcovidorsymptoms() { + driver.findElement(By.id("searchBox")).sendKeys("COVID or SYMPTOMS"); + } + + @Then("all results for COVID or SYMPTOMS will be displayed.") + public void alltheresultsforcovidorsymptomswillbedisplayed() { + driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); + } + //Simple Search using a date range + + @When("I click the Advanced Filter icon.") + public void iclicktheadvancedfiltericon() { + WebElement element = driver.findElement(By.xpath("//button[@title='Advanced Filters']")); + WebDriverWait wait = new WebDriverWait(driver, 5); //here, wait time is 5 seconds + wait.until(ExpectedConditions.visibilityOf(element)); //this will wait for element to be visible for 20 seconds + element.click(); //now it clicks on element + } + + @When("I click the From box.") + public void iclickthefrombox() { + //"FROM BOX" + WebElement element = driver.findElement(By.xpath("//input[@class='form-control']")); + WebDriverWait wait = new WebDriverWait(driver, 5); //here, wait time is 5 seconds + wait.until(ExpectedConditions.visibilityOf(element)); //this will wait for element to be visible for 20 seconds + element.click(); //now it clicks on element + } + + @When("I enter 2021-03-03.") + public void ienter20210303() { + //"Enters start date. This is the line for the FROM Date Picker") + driver.findElement(By.xpath("//input[@class='form-control']")).sendKeys("2021-03-03"); + } + + @When("I click the To box.") + public void iclickthetobox() { + //"TO BOX" + WebElement element = driver.findElement(By.xpath("(//input[@class='form-control'])[2]")); + WebDriverWait wait = new WebDriverWait(driver, 5); //here, wait time is 5 seconds + wait.until(ExpectedConditions.visibilityOf(element)); //this will wait for element to be visible for 20 seconds + element.click(); //now it clicks on element + } + + @When("I enter 2021-04-26.") + public void ienter20210426() { + //"Enters start date. This is the line for the To Date Picker") + driver.findElement(By.xpath("(//input[@class='form-control'])[2]")).sendKeys("2021-04-26"); + + } + + @When("I click the Apply filters button.") + public void iclicktheapplyfiltersbutton() { + //Clicks apply filter button + driver.findElement(By.xpath("//button[contains(@class,'btn btn-sm')]")).click(); + + } + + @Then("all publications will be displayed.") + public void allpublicationswithinthedaterangewillbedisplayedandiamdonewithmytest() { + driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); + } + + +} \ No newline at end of file diff --git a/cucumberTest/src/test/resources/iCite/SimpleSearch.feature b/cucumberTest/src/test/resources/iCite/SimpleSearch.feature new file mode 100644 index 0000000..ebecd66 --- /dev/null +++ b/cucumberTest/src/test/resources/iCite/SimpleSearch.feature @@ -0,0 +1,7 @@ +Feature: Performing a search. + Scenario: As a user, I want to perform a Search. + Given I am on the iCite page. + When I click my mouse in the Search query field. + And I enter pcsk9. + And I click the magnifying glass. + Then the results for pcsk9 will be displayed. \ No newline at end of file diff --git a/cucumberTest/src/test/resources/iCite/SimpleSearch2.feature b/cucumberTest/src/test/resources/iCite/SimpleSearch2.feature new file mode 100644 index 0000000..dffb04a --- /dev/null +++ b/cucumberTest/src/test/resources/iCite/SimpleSearch2.feature @@ -0,0 +1,7 @@ +Feature: Performing a search with AND function +Scenario: As a user, I want to perform a search using the AND function. + Given I am on the iCite page. + When I click my mouse in the Search query field. + And I search for COVID and SYMPTOMS. + And I click the magnifying glass. + Then all results for COVID as well as SYMPTOMS will be displayed. diff --git a/cucumberTest/src/test/resources/iCite/SimpleSearch3.feature b/cucumberTest/src/test/resources/iCite/SimpleSearch3.feature new file mode 100644 index 0000000..a2fa6a5 --- /dev/null +++ b/cucumberTest/src/test/resources/iCite/SimpleSearch3.feature @@ -0,0 +1,7 @@ +Feature: Search with OR + Scenario: As a user, I want to perform a search using the OR function. + Given I am on the iCite page. + When I click my mouse in the Search query field. + And I search for COVID or SYMPTOMS. + And I click the magnifying glass. + Then all results for COVID or SYMPTOMS will be displayed. diff --git a/cucumberTest/src/test/resources/iCite/SimpleSearch4.feature b/cucumberTest/src/test/resources/iCite/SimpleSearch4.feature new file mode 100644 index 0000000..a2e8e13 --- /dev/null +++ b/cucumberTest/src/test/resources/iCite/SimpleSearch4.feature @@ -0,0 +1,14 @@ +Feature: Searching by date range. + Scenario: As a user, I want to perform a search by a date range. + Given I am on the iCite page. + When I click the Advanced Filter icon. + And I click the From box. + And I enter 2021-03-03. + And I click the To box. + And I enter 2021-04-26. + And I click the Apply filters button. + Then all publications will be displayed. + + + +