init
This commit is contained in:
commit
4f4c37bc53
26 files changed
+953
No files matched your search
@@ -0,0 +1,104 @@
|
||||
package steps;
|
||||
|
||||
import Utils.ColorFormatter;
|
||||
import com.codeborne.selenide.Condition;
|
||||
import com.codeborne.selenide.ex.ElementNotFound;
|
||||
import io.cucumber.java.en.And;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.openqa.selenium.By;
|
||||
import org.passay.CharacterData;
|
||||
import org.passay.CharacterRule;
|
||||
import org.passay.EnglishCharacterData;
|
||||
import org.passay.PasswordGenerator;
|
||||
import pages.EsetHomePage;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.codeborne.selenide.Selenide.$;
|
||||
import static com.codeborne.selenide.Selenide.page;
|
||||
import static frameworkContext.ContextFactory.getContext;
|
||||
|
||||
@Slf4j
|
||||
public class EsetHomeSteps extends Steps {
|
||||
|
||||
EsetHomePage webPage = page(EsetHomePage.class);
|
||||
|
||||
@And("EsetHomePage: Click button {string}")
|
||||
public void esethomepageClickButton(String buttonName) {
|
||||
$(By.xpath("//*[text()='%s' and not(self::b)]"
|
||||
.formatted(buttonName)))
|
||||
.scrollIntoCenter()
|
||||
.click();
|
||||
}
|
||||
|
||||
@And("EsetHomePage: Accept cookies")
|
||||
public void esethomepageAcceptCookies() {
|
||||
try {
|
||||
webPage.cookiesConsentAcceptButton
|
||||
.shouldBe(Condition.visible, Duration.ofSeconds(5))
|
||||
.scrollIntoCenter()
|
||||
.click();
|
||||
} catch (ElementNotFound e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@And("EsetHomePage: Enter saved temporary email address")
|
||||
public void esethomepageFillSavedEmail() {
|
||||
webPage.accountEmailField.scrollIntoCenter().setValue(getContext().getTempEmail());
|
||||
}
|
||||
|
||||
@And("EsetHomePage: Enter generated password")
|
||||
public void esethomepageFillGeneratedPassword() {
|
||||
String password = generatePassword(12);
|
||||
|
||||
webPage.accountPasswordField.scrollIntoCenter().setValue(password);
|
||||
|
||||
log.info("Password entered: {}", ColorFormatter.RED.toConsole(password));
|
||||
}
|
||||
|
||||
@And("EsetHomePage: Choose system {string}")
|
||||
public void esethomepageChooseSystem(String systemName) {
|
||||
$(By.xpath("//button[@data-label='device-protect-os-card-%s-button']"
|
||||
.formatted(systemName)))
|
||||
.scrollIntoCenter()
|
||||
.click();
|
||||
}
|
||||
|
||||
@And("EsetHomePage: Read ESET Smart Security activation code")
|
||||
public void esethomepageReadESETSmartSecurityActivationCode() {
|
||||
String key = $(By.xpath("//p[text()='Klucz aktywacji']/..//following-sibling::*[1]/p")).getText();
|
||||
|
||||
log.info("""
|
||||
|
||||
ESET Smart Security activation key found:
|
||||
|
||||
=---------------------------=
|
||||
{}
|
||||
=---------------------------=
|
||||
|
||||
""", ColorFormatter.GREEN.toConsole(key));
|
||||
}
|
||||
|
||||
public static String generatePassword(int length) {
|
||||
PasswordGenerator generator = new PasswordGenerator();
|
||||
List<CharacterRule> rules = Arrays.asList(
|
||||
new CharacterRule(EnglishCharacterData.LowerCase, 1),
|
||||
new CharacterRule(EnglishCharacterData.UpperCase, 1),
|
||||
new CharacterRule(EnglishCharacterData.Digit, 1),
|
||||
new CharacterRule(new CharacterData() {
|
||||
public String getErrorCode() {
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
public String getCharacters() {
|
||||
return "!@#$%^&*";
|
||||
}
|
||||
}, 1)
|
||||
);
|
||||
|
||||
return generator.generatePassword(length, rules);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user