<commit_before>package bla.tm.steps.products_and_docs;

import bla.tm.pages.site.products_and_docs.PD_Widget_CountdownPage;
import net.serenitybdd.core.Serenity;
import net.serenitybdd.core.pages.WebElementFacade;
import net.thucydides.core.annotations.Step;
import org.junit.Assert;
import org.openqa.selenium.Keys;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import static bla.tm.staticmethods.StaticMethods.*;
import static net.thucydides.core.webdriver.ThucydidesWebDriverSupport.getDriver;
import static org.junit.Assert.assertEquals;

public class PD_Widget_CountdownSteps {

    PD_Widget_CountdownPage countdownWidgetPage;

    @Step
    public void openPage() {
        countdownWidgetPage.open();
    }

    @Step
    public void closePage() {
        countdownWidgetPage.closeWindow();
    }

    @Step
    public void maximiseBrowserWindow() {
        countdownWidgetPage.maximisePageWindow();
    }

    @Step
    public void checkIfTitleIsCorrect(){
        assertEquals (countdownWidgetPage.getTitleText(), countdownWidgetPage.pageHeader);
    }

    @Step
    public void checkGeneralPageElements(boolean disqus, boolean leftMenu){
        countdownWidgetPage.checkGeneralPageElements(disqus, leftMenu);
    }

    @Step
    public void clickLogIn() {
        countdownWidgetPage.getLogInButton().click();
    }

    @Step
    public void checkAPIKeyPlaceholders(String apikey) {
        if ("{apikey}".equals(apikey)){
            assertEquals(countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().getAttribute("value"), "5QGCEXAsJowiCI4n1uAwMlCGAcSNAEmG");
        }
        else {
            waitForSomeActionHappened(50);
            assertEquals(countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().getAttribute("value"), apikey);
        }
    }

    public void apiKeyFieldIsNotEmpty() {
        String apiKey = countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().getValue();
        Assert.assertFalse(apiKey == null || apiKey.length() == 0);
    }

    public void eventIdFieldIsNotEmpty() {
        String eventId = countdownWidgetPage.getCountdownWidget().getEventIDTextField().getValue();
        Assert.assertFalse(eventId == null || eventId.length() == 0);
    }

    public void storeCurrentApiKey() {
        String apiKey = countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().getValue();
        Serenity.getCurrentSession().put("apiKey", apiKey);
    }

    public void storeCurrentEventId() {
        String eventId = countdownWidgetPage.getCountdownWidget().getEventIDTextField().getValue();
        Serenity.getCurrentSession().put("eventId", eventId);
    }

    public void clickOnGetButton() {
        WebElementFacade getCodeBtn = countdownWidgetPage.getCountdownWidget().getGetCodeButton();
        scrollToElement(getCodeBtn);
        getCodeBtn.click();
    }

    public void thePopupEmbeddedCodeIsOpened() {
        Assert.assertTrue(countdownWidgetPage.getCountdownWidget().getEmbeddedHtmlCode().isDisplayed());
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public void embeddedCodeContainsStoredApiKey() {
        String embeddedApiKeyValue = countdownWidgetPage.getCountdownWidget().getEmbeddedApiKey();
        String apiKeyValue = (String) Serenity.getCurrentSession().get("apiKey");
        Assert.assertEquals(String.format("The embedded code api key value is: %s but the apiKey value which was stored before is: %s ", embeddedApiKeyValue, apiKeyValue), apiKeyValue, embeddedApiKeyValue);
    }

    public void embeddedCodeContainsStoredEventId() {
        String embeddedEventIdValue = countdownWidgetPage.getCountdownWidget().getEmbeddedEventId();
        String eventIdValue = (String) Serenity.getCurrentSession().get("eventId");
        Assert.assertEquals(String.format("The embedded code eventId value is: %s but the eventId value which was stored before is: %s ", embeddedEventIdValue, eventIdValue), eventIdValue, embeddedEventIdValue);
    }

    public void submitForm() {
        countdownWidgetPage.getCountdownWidget().getEventIDTextField().sendKeys(Keys.ENTER);
    }

    public void setApiKey(String apiKey) {
        countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().clear();
        countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().sendKeys(apiKey);
    }

    public void setEventId(String eventId) {
        countdownWidgetPage.getCountdownWidget().getEventIDTextField().clear();
        countdownWidgetPage.getCountdownWidget().getEventIDTextField().sendKeys(eventId);
    }

    public void clickResetButton() {
        countdownWidgetPage.getCountdownWidget().getResetButton().click();
    }

    public void apiKeyFieldContainsStoredValue() {
        String actualApiKey = countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().getValue();
        String expectedApiKey = (String) Serenity.getCurrentSession().get("apiKey");<commit_msg>- clickResetButton() HOT FIX<commit_after>package bla.tm.steps.products_and_docs;

import bla.tm.pages.site.products_and_docs.PD_Widget_CountdownPage;
import net.serenitybdd.core.Serenity;
import net.serenitybdd.core.pages.WebElementFacade;
import net.thucydides.core.annotations.Step;
import org.junit.Assert;
import org.openqa.selenium.Keys;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import static bla.tm.staticmethods.StaticMethods.*;
import static net.thucydides.core.webdriver.ThucydidesWebDriverSupport.getDriver;
import static org.junit.Assert.assertEquals;

public class PD_Widget_CountdownSteps {

    PD_Widget_CountdownPage countdownWidgetPage;

    @Step
    public void openPage() {
        countdownWidgetPage.open();
    }

    @Step
    public void closePage() {
        countdownWidgetPage.closeWindow();
    }

    @Step
    public void maximiseBrowserWindow() {
        countdownWidgetPage.maximisePageWindow();
    }

    @Step
    public void checkIfTitleIsCorrect(){
        assertEquals (countdownWidgetPage.getTitleText(), countdownWidgetPage.pageHeader);
    }

    @Step
    public void checkGeneralPageElements(boolean disqus, boolean leftMenu){
        countdownWidgetPage.checkGeneralPageElements(disqus, leftMenu);
    }

    @Step
    public void clickLogIn() {
        countdownWidgetPage.getLogInButton().click();
    }

    @Step
    public void checkAPIKeyPlaceholders(String apikey) {
        if ("{apikey}".equals(apikey)){
            assertEquals(countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().getAttribute("value"), "5QGCEXAsJowiCI4n1uAwMlCGAcSNAEmG");
        }
        else {
            waitForSomeActionHappened(50);
            assertEquals(countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().getAttribute("value"), apikey);
        }
    }

    public void apiKeyFieldIsNotEmpty() {
        String apiKey = countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().getValue();
        Assert.assertFalse(apiKey == null || apiKey.length() == 0);
    }

    public void eventIdFieldIsNotEmpty() {
        String eventId = countdownWidgetPage.getCountdownWidget().getEventIDTextField().getValue();
        Assert.assertFalse(eventId == null || eventId.length() == 0);
    }

    public void storeCurrentApiKey() {
        String apiKey = countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().getValue();
        Serenity.getCurrentSession().put("apiKey", apiKey);
    }

    public void storeCurrentEventId() {
        String eventId = countdownWidgetPage.getCountdownWidget().getEventIDTextField().getValue();
        Serenity.getCurrentSession().put("eventId", eventId);
    }

    public void clickOnGetButton() {
        WebElementFacade getCodeBtn = countdownWidgetPage.getCountdownWidget().getGetCodeButton();
        scrollToElement(getCodeBtn);
        getCodeBtn.click();
    }

    public void thePopupEmbeddedCodeIsOpened() {
        Assert.assertTrue(countdownWidgetPage.getCountdownWidget().getEmbeddedHtmlCode().isDisplayed());
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public void embeddedCodeContainsStoredApiKey() {
        String embeddedApiKeyValue = countdownWidgetPage.getCountdownWidget().getEmbeddedApiKey();
        String apiKeyValue = (String) Serenity.getCurrentSession().get("apiKey");
        Assert.assertEquals(String.format("The embedded code api key value is: %s but the apiKey value which was stored before is: %s ", embeddedApiKeyValue, apiKeyValue), apiKeyValue, embeddedApiKeyValue);
    }

    public void embeddedCodeContainsStoredEventId() {
        String embeddedEventIdValue = countdownWidgetPage.getCountdownWidget().getEmbeddedEventId();
        String eventIdValue = (String) Serenity.getCurrentSession().get("eventId");
        Assert.assertEquals(String.format("The embedded code eventId value is: %s but the eventId value which was stored before is: %s ", embeddedEventIdValue, eventIdValue), eventIdValue, embeddedEventIdValue);
    }

    public void submitForm() {
        countdownWidgetPage.getCountdownWidget().getEventIDTextField().sendKeys(Keys.ENTER);
    }

    public void setApiKey(String apiKey) {
        countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().clear();
        countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().sendKeys(apiKey);
    }

    public void setEventId(String eventId) {
        countdownWidgetPage.getCountdownWidget().getEventIDTextField().clear();
        countdownWidgetPage.getCountdownWidget().getEventIDTextField().sendKeys(eventId);
    }

    public void clickResetButton() {
        scrollToElement(countdownWidgetPage.getCountdownWidget().getResetButton());
        countdownWidgetPage.getCountdownWidget().getResetButton().click();
    }

    public void apiKeyFieldContainsStoredValue() {
        String actualApiKey = countdownWidgetPage.getCountdownWidget().getAPIKeyTextField().getValue();
        String expectedApiKey = (String) Serenity.getCurrentSession().get("apiKey");
{'fraction_non_alphanumeric': 0.1033434650455927, 'fraction_numerical': 0.0021570742229630358, 'mean_word_length': 4.054509415262636, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3233111', 'n_tokens_mistral': 2850, 'n_tokens_neox': 2804, 'n_words': 459}