626: extract hardcoded selectors into variables
This commit is contained in:
parent
397de01d0e
commit
bf1f78e7b4
2 changed files with 32 additions and 21 deletions
|
@ -1,5 +1,6 @@
|
|||
package com.provectus.kafka.ui.pages;
|
||||
|
||||
import com.codeborne.selenide.SelenideElement;
|
||||
import lombok.SneakyThrows;
|
||||
import org.openqa.selenium.By;
|
||||
|
||||
|
@ -7,6 +8,11 @@ import static com.codeborne.selenide.Selenide.$;
|
|||
|
||||
public class TopicViewPage {
|
||||
|
||||
public SelenideElement cleanupPolicy = $(By.name("cleanupPolicy"));
|
||||
public SelenideElement timeToRetain = $(By.id("timeToRetain"));
|
||||
public SelenideElement maxSizeOnDisk = $(By.name("retentionBytes"));
|
||||
public SelenideElement maxMessageBytes = $(By.name("maxMessageBytes"));
|
||||
|
||||
@SneakyThrows
|
||||
public TopicViewPage openEditSettings() {
|
||||
$(By.xpath("//a[@class=\"button\" and text()='Edit settings']")).click();
|
||||
|
@ -15,35 +21,34 @@ public class TopicViewPage {
|
|||
|
||||
@SneakyThrows
|
||||
public TopicViewPage changeCleanupPolicy(String cleanupPolicyValue) {
|
||||
$(By.name("cleanupPolicy")).click();
|
||||
cleanupPolicy.click();
|
||||
$(By.xpath("//select/option[@value = '%s']".formatted(cleanupPolicyValue))).click();
|
||||
return this;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public TopicViewPage changeTimeToRetainValue(String timeToRetainValue) {
|
||||
$(By.id("timeToRetain")).clear();
|
||||
$(By.id("timeToRetain")).sendKeys(String.valueOf(timeToRetainValue));
|
||||
timeToRetain.clear();
|
||||
timeToRetain.sendKeys(String.valueOf(timeToRetainValue));
|
||||
return this;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public TopicViewPage changeMaxSizeOnDisk(String maxSizeOnDisk) {
|
||||
$(By.name("retentionBytes")).click();
|
||||
$(By.xpath("//select/option[text() = '%s']".formatted(maxSizeOnDisk))).click();
|
||||
public TopicViewPage changeMaxSizeOnDisk(String maxSizeOnDiskValue) {
|
||||
maxSizeOnDisk.click();
|
||||
$(By.xpath("//select/option[text() = '%s']".formatted(maxSizeOnDiskValue))).click();
|
||||
return this;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public TopicViewPage changeMaxMessageBytes(String maxMessageBytes) {
|
||||
$(By.name("maxMessageBytes")).clear();
|
||||
$(By.name("maxMessageBytes")).sendKeys(String.valueOf(maxMessageBytes));
|
||||
public TopicViewPage changeMaxMessageBytes(String maxMessageBytesValue) {
|
||||
maxMessageBytes.clear();
|
||||
maxMessageBytes.sendKeys(String.valueOf(maxMessageBytesValue));
|
||||
return this;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public TopicViewPage submitSettingChanges() {
|
||||
public void submitSettingChanges() {
|
||||
$(By.xpath("//input[@type='submit']")).click();
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -3,18 +3,22 @@ package com.provectus.kafka.ui.topics;
|
|||
import com.provectus.kafka.ui.base.BaseTest;
|
||||
import com.provectus.kafka.ui.helpers.Helpers;
|
||||
import com.provectus.kafka.ui.pages.MainPage;
|
||||
import com.provectus.kafka.ui.pages.TopicViewPage;
|
||||
import lombok.SneakyThrows;
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.openqa.selenium.By;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static com.codeborne.selenide.Selenide.$;
|
||||
|
||||
public class TopicTests extends BaseTest {
|
||||
|
||||
public static final String UPDATE_TOPIC = "update-topic";
|
||||
public static final String NEW_TOPIC = "new-topic";
|
||||
public static final String SECOND_LOCAL = "secondLocal";
|
||||
public static final String COMPACT_POLICY_VALUE = "compact";
|
||||
public static final String UPDATED_TIME_TO_RETAIN_VALUE = "604800001";
|
||||
public static final String UPDATED_MAX_SIZE_ON_DISK = "20 GB";
|
||||
public static final String UPDATED_MAX_MESSAGE_BYTES = "1000020";
|
||||
|
||||
@BeforeAll
|
||||
@SneakyThrows
|
||||
|
@ -54,17 +58,19 @@ public class TopicTests extends BaseTest {
|
|||
.openTopic(UPDATE_TOPIC);
|
||||
pages.openTopicViewPage(path)
|
||||
.openEditSettings()
|
||||
.changeCleanupPolicy("compact")
|
||||
.changeTimeToRetainValue("604800001")
|
||||
.changeMaxSizeOnDisk("20 GB")
|
||||
.changeMaxMessageBytes("1000020")
|
||||
.changeCleanupPolicy(COMPACT_POLICY_VALUE)
|
||||
.changeTimeToRetainValue(UPDATED_TIME_TO_RETAIN_VALUE)
|
||||
.changeMaxSizeOnDisk(UPDATED_MAX_SIZE_ON_DISK)
|
||||
.changeMaxMessageBytes(UPDATED_MAX_MESSAGE_BYTES)
|
||||
.submitSettingChanges();
|
||||
pages.reloadPage();
|
||||
pages.openTopicViewPage(path)
|
||||
TopicViewPage topicViewPage = pages.openTopicViewPage(path)
|
||||
.openEditSettings();
|
||||
|
||||
String cleanupPolicy = $(By.name("cleanupPolicy")).getSelectedValue();
|
||||
Assert.assertEquals("compact", cleanupPolicy);
|
||||
Assertions.assertEquals(COMPACT_POLICY_VALUE, topicViewPage.cleanupPolicy.getSelectedValue());
|
||||
Assertions.assertEquals(UPDATED_TIME_TO_RETAIN_VALUE,topicViewPage.timeToRetain.getValue());
|
||||
Assertions.assertEquals(UPDATED_MAX_SIZE_ON_DISK,topicViewPage.maxSizeOnDisk.getSelectedText());
|
||||
Assertions.assertEquals(UPDATED_MAX_MESSAGE_BYTES,topicViewPage.maxMessageBytes.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue