verify Step annotation cross page methods #2434 (#2448)

Co-authored-by: Vlad Senyuta <66071557+VladSenyuta@users.noreply.github.com>
This commit is contained in:
Arthur 2022-08-18 11:16:00 +03:00 committed by GitHub
parent a665fb4d83
commit a5f539c62a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 58 additions and 37 deletions

View file

@ -33,10 +33,11 @@ public class MainPage {
}
@SneakyThrows
@Step
public void topicIsVisible(String topicName) {
new TopicsList().isTopicVisible(topicName);
}
@Step
public void topicIsNotVisible(String topicName){
new TopicsList().isTopicNotVisible(topicName);
}

View file

@ -5,6 +5,7 @@ import com.provectus.kafka.ui.pages.connector.ConnectorsView;
import com.provectus.kafka.ui.pages.schema.SchemaRegistryList;
import com.provectus.kafka.ui.pages.topic.TopicView;
import com.provectus.kafka.ui.pages.topic.TopicsList;
import io.qameta.allure.Step;
public class Pages {
@ -18,26 +19,32 @@ public class Pages {
public ConnectorsView connectorsView = new ConnectorsView();
public SchemaRegistryList schemaRegistry = new SchemaRegistryList();
@Step
public MainPage open() {
return openMainPage();
}
@Step
public MainPage openMainPage() {
return mainPage.goTo();
}
@Step
public TopicsList openTopicsList(String clusterName) {
return topicsList.goTo(clusterName);
}
@Step
public TopicView openTopicView(String clusterName, String topicName) {
return topicView.goTo(clusterName, topicName);
}
@Step
public ConnectorsList openConnectorsList(String clusterName) {
return connectorsList.goTo(clusterName);
}
@Step
public ConnectorsView openConnectorsView(String clusterName, String connectorName) {
return connectorsView.goTo(clusterName, connectorName);
}

View file

@ -3,6 +3,7 @@ package com.provectus.kafka.ui.pages;
import com.codeborne.selenide.Condition;
import com.codeborne.selenide.SelenideElement;
import com.provectus.kafka.ui.pages.topic.TopicView;
import io.qameta.allure.Step;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.support.ui.ExpectedConditions;
@ -16,26 +17,26 @@ public class ProduceMessagePage{
private final SelenideElement contentField = $(By.xpath("//div[@id = 'content']/textarea"));
private final SelenideElement headersField = $(By.xpath("//div[@id = 'headers']/textarea"));
private final SelenideElement sendBtn = $(By.xpath("//button[@type = 'submit']"));
@Step
public ProduceMessagePage setKeyField(String value) {
Wait().until(ExpectedConditions.urlContains("message"));
keyField.sendKeys(Keys.chord(Keys.DELETE));
keyField.setValue(value);
return this;
}
@Step
public ProduceMessagePage setContentFiled(String value) {
Wait().until(ExpectedConditions.urlContains("message"));
contentField.sendKeys(Keys.DELETE);
contentField.setValue(value);
return this;
}
@Step
public ProduceMessagePage setHeaderFiled(String value) {
headersField.setValue(value);
return new ProduceMessagePage();
}
@Step
public TopicView submitProduceMessage() {
sendBtn.shouldBe(Condition.visible).click();
return new TopicView();

View file

@ -36,12 +36,14 @@ public class ConnectorsList {
}
@SneakyThrows
@Step
public ConnectorsList openConnector(String connectorName) {
$(By.linkText(connectorName)).click();
return this;
}
@SneakyThrows
@Step
public ConnectorsList isNotVisible(String connectorName) {
$(By.xpath("//table")).shouldBe(Condition.visible);
$x("//tbody//td[1]//a[text()='" + connectorName + "']").shouldBe(Condition.not(Condition.visible));
@ -54,7 +56,7 @@ public class ConnectorsList {
$$(By.linkText(topicName));
return this;
}
@Step
public ConnectorsList connectorIsUpdatedInList(String connectorName, String topicName) {
$(By.xpath(String.format("//a[text() = '%s']", connectorName))).shouldBe(Condition.visible);
By.xpath(String.format("//a[text() = '%s']", topicName)).refreshUntil(Condition.visible);

View file

@ -2,6 +2,7 @@ package com.provectus.kafka.ui.pages.schema;
import com.codeborne.selenide.SelenideElement;
import com.provectus.kafka.ui.utils.BrowserUtils;
import io.qameta.allure.Step;
import org.openqa.selenium.By;
import static com.codeborne.selenide.Selenide.$;
@ -12,23 +13,23 @@ public class SchemaCreateView {
private final SelenideElement subjectName = $(By.xpath("//input[@name='subject']"));
private final SelenideElement schemaField = $(By.xpath("//textarea[@name='schema']"));
private final SelenideElement submitSchemaButton = $(By.xpath("//button[@type='submit']"));
@Step
public SchemaCreateView selectSchemaTypeFromDropdown(SchemaType schemaType) {
$("ul[role='listbox']").click();
$x("//li[text()='" + schemaType.getValue() + "']").click();
return this;
}
@Step
public SchemaView clickSubmit() {
BrowserUtils.javaExecutorClick(submitSchemaButton);
return new SchemaView();
}
@Step
public SchemaCreateView setSubjectName(String name) {
subjectName.setValue(name);
return this;
}
@Step
public SchemaCreateView setSchemaField(String text) {
schemaField.setValue(text);
return this;

View file

@ -16,19 +16,19 @@ public class SchemaEditView {
SelenideElement newSchemaTextArea = $("#newSchema [wrap]");
@Step
public SchemaEditView selectSchemaTypeFromDropdown(SchemaCreateView.SchemaType schemaType) {
$x("//ul[@name='schemaType']").click();
$x("//li[text()='" + schemaType.getValue() + "']").click();
return this;
}
@Step
public SchemaEditView selectCompatibilityLevelFromDropdown(CompatibilityLevel.CompatibilityEnum level) {
$x("//ul[@name='compatibilityLevel']").click();
$x("//li[text()='" + level.getValue() + "']").click();
return this;
}
@Step
public SchemaView clickSubmit() {
BrowserUtils.javaExecutorClick($(By.xpath("//button[@type='submit']")));
return new SchemaView();
@ -43,7 +43,7 @@ public class SchemaEditView {
return this;
}
@Step
public SchemaRegistryList removeSchema() {
$(By.xpath("//*[contains(text(),'Remove')]")).click();
$(By.xpath("//*[text()='Confirm']")).shouldBe(Condition.visible).click();

View file

@ -12,18 +12,19 @@ import static com.codeborne.selenide.Selenide.*;
public class SchemaRegistryList {
private final SelenideElement schemaButton = $(By.xpath("//*[contains(text(),'Create Schema')]"));
@Step
public SchemaCreateView clickCreateSchema() {
BrowserUtils.javaExecutorClick(schemaButton);
return new SchemaCreateView();
}
@Step
public SchemaView openSchema(String schemaName) {
$(By.xpath("//*[contains(text(),'" + schemaName + "')]")).click();
return new SchemaView();
}
@SneakyThrows
@Step
public SchemaRegistryList isNotVisible(String schemaName) {
$x(String.format("//*[contains(text(),'%s')]",schemaName)).shouldNotBe(Condition.visible);
return this;

View file

@ -28,7 +28,7 @@ public class SchemaView {
$x("//button[text()= 'Edit Schema']").click();
return new SchemaEditView();
}
@Step
public SchemaRegistryList removeSchema() {
BrowserUtils.javaExecutorClick($(".dropdown.is-right button"));
$(By.xpath("//*[contains(text(),'Remove')]")).click();

View file

@ -4,6 +4,7 @@ import com.codeborne.selenide.ClickOptions;
import com.codeborne.selenide.Condition;
import com.codeborne.selenide.ElementsCollection;
import com.codeborne.selenide.SelenideElement;
import io.qameta.allure.Step;
import org.openqa.selenium.By;
import com.provectus.kafka.ui.utils.BrowserUtils;
@ -14,43 +15,43 @@ public class TopicCreateEditSettingsView {
private final SelenideElement timeToRetain = $(By.cssSelector("input#timeToRetain"));
private final SelenideElement maxMessageBytes = $(By.name("maxMessageBytes"));
@Step
public TopicCreateEditSettingsView setTopicName(String topicName) {
$("input#topicFormName").setValue(topicName);
return this;
}
@Step
public TopicCreateEditSettingsView setMinInsyncReplicas(Integer minInsyncReplicas) {
$("input[name=minInsyncReplicas]").setValue(minInsyncReplicas.toString());
$("input[name=minInSyncReplicas]").setValue(minInsyncReplicas.toString());
return this;
}
@Step
public TopicCreateEditSettingsView setTimeToRetainDataInMs(Long ms) {
timeToRetain.setValue(ms.toString());
return this;
}
@Step
public TopicCreateEditSettingsView setTimeToRetainDataInMs(String ms) {
timeToRetain.setValue(ms);
return this;
}
@Step
public TopicCreateEditSettingsView setMaxSizeOnDiskInGB(String value) {
KafkaUISelectElement kafkaUISelectElement = new KafkaUISelectElement("retentionBytes");
kafkaUISelectElement.selectByVisibleText(value);
return this;
}
@Step
public TopicCreateEditSettingsView setMaxMessageBytes(Long bytes) {
maxMessageBytes.setValue(bytes.toString());
return this;
}
@Step
public TopicCreateEditSettingsView setMaxMessageBytes(String bytes) {
return setMaxMessageBytes(Long.parseLong(bytes));
}
@Step
public TopicCreateEditSettingsView setTimeToRetainDataInMsUsingButtons(String value) {
timeToRetain
.parent()
@ -61,31 +62,31 @@ public class TopicCreateEditSettingsView {
return this;
}
@Step
public TopicCreateEditSettingsView selectCleanupPolicy(CleanupPolicyValue cleanupPolicyValue) {
return selectFromDropDownByOptionValue("cleanupPolicy",
cleanupPolicyValue.getOptionValue());
}
@Step
public TopicCreateEditSettingsView selectCleanupPolicy(String cleanupPolicyOptionValue) {
$("ul#topicFormCleanupPolicy").click();
$x("//li[text()='" + cleanupPolicyOptionValue + "']").click();
return this;
}
@Step
public TopicCreateEditSettingsView selectRetentionBytes(String visibleValue) {
return selectFromDropDownByVisibleText("retentionBytes", visibleValue);
}
@Step
public TopicCreateEditSettingsView selectRetentionBytes(Long optionValue) {
return selectFromDropDownByOptionValue("retentionBytes", optionValue.toString());
}
@Step
public TopicView sendData() {
BrowserUtils.javaExecutorClick($x("//button[@type='submit']"));
return new TopicView();
}
@Step
public TopicCreateEditSettingsView addCustomParameter(String customParameterName,
String customParameterValue) {
ElementsCollection customParametersElements =
@ -109,7 +110,7 @@ public class TopicCreateEditSettingsView {
.setValue(customParameterValue);
return this;
}
@Step
public TopicCreateEditSettingsView updateCustomParameter(String customParameterName,
String customParameterValue) {
SelenideElement selenideElement = $$("ul[role=listbox][name^=customParams][name$=name]")
@ -121,7 +122,7 @@ public class TopicCreateEditSettingsView {
$(String.format("input[name^=%s]", name)).setValue(customParameterValue);
return this;
}
@Step
public TopicCreateEditSettingsView cleanupPolicyIs(String value) {
String cleanupPolicy = new KafkaUISelectElement("cleanupPolicy")
.getCurrentValue();
@ -130,7 +131,7 @@ public class TopicCreateEditSettingsView {
.isEqualToIgnoringCase(value);
return this;
}
@Step
public TopicCreateEditSettingsView timeToRetainIs(String time) {
String value = timeToRetain.getValue();
assertThat(value)
@ -138,7 +139,7 @@ public class TopicCreateEditSettingsView {
.isEqualTo(time);
return this;
}
@Step
public TopicCreateEditSettingsView maxSizeOnDiskIs(String size) {
String retentionBytes = new KafkaUISelectElement("retentionBytes")
.getCurrentValue();
@ -147,7 +148,7 @@ public class TopicCreateEditSettingsView {
.isEqualTo(size);
return this;
}
@Step
public TopicCreateEditSettingsView maxMessageBytesIs(String bytes) {
String value = maxMessageBytes.getValue();
assertThat(value)

View file

@ -35,6 +35,7 @@ public class TopicView {
}
@SneakyThrows
@Step
public TopicCreateEditSettingsView openEditSettings() {
BrowserUtils.javaExecutorClick(dotMenuHeader);
$x("//a[text()= '" + DotMenuHeaderItems.EDIT_SETTINGS.getValue() + "']").click();
@ -48,6 +49,7 @@ public class TopicView {
}
@SneakyThrows
@Step
public TopicsList deleteTopic() {
BrowserUtils.javaExecutorClick(dotMenuHeader);
$("#dropdown-menu").$(byLinkText(DotMenuHeaderItems.REMOVE_TOPIC.getValue())).click();
@ -56,15 +58,18 @@ public class TopicView {
}
@SneakyThrows
@Step
public ProduceMessagePage clickOnButton(String buttonName) {
BrowserUtils.javaExecutorClick($(By.xpath(String.format("//div//button[text()='%s']", buttonName))));
return new ProduceMessagePage();
}
@Step
public boolean isKeyMessageVisible(String keyMessage) {
return keyMessage.equals($("td[title]").getText());
}
@Step
public boolean isContentMessageVisible(String contentMessage) {
return contentMessage.matches($x("//html//div[@id='root']/div/main//table//p").getText().trim());
}

View file

@ -47,12 +47,14 @@ public class TopicsList {
}
@SneakyThrows
@Step
public TopicView openTopic(String topicName) {
$(By.linkText(topicName)).click();
return new TopicView();
}
@SneakyThrows
@Step
public TopicsList isTopicNotVisible(String topicName) {
$$x("//table/tbody/tr/td[2]")
.shouldBe(CollectionCondition.sizeGreaterThan(0))