Skip to content

Commit 8a659d5

Browse files
committed
fix menu locators and clearByKeyboard()
1 parent 1e5459b commit 8a659d5

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

e2e-tests/src/main/java/io/kafbat/ui/screens/panels/NaviSideBar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
public class NaviSideBar extends BasePage {
1818

1919
protected SelenideElement dashboardMenuItem = $x("//a[@title='Dashboard']");
20-
protected String sideMenuOptionElementLocator = ".//ul/li[contains(.,'%s')]";
20+
protected String sideMenuOptionElementLocator = ".//ul/a[@title='%s']";
2121
protected String clusterElementLocator = "//aside/ul/li[contains(.,'%s')]";
2222

2323
private SelenideElement expandCluster(String clusterName) {
2424
SelenideElement clusterElement = $x(String.format(clusterElementLocator, clusterName)).shouldBe(Condition.visible);
25-
if (clusterElement.parent().$$x(".//ul").size() == 0) {
25+
if (clusterElement.parent().$$x(".//ul").isEmpty()) {
2626
WebUtil.clickByActions(clusterElement);
2727
}
2828
return clusterElement;

e2e-tests/src/main/java/io/kafbat/ui/screens/topics/TopicCreateEditForm.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.kafbat.ui.screens.topics;
22

3+
import static com.codeborne.selenide.Condition.enabled;
34
import static com.codeborne.selenide.Selenide.$;
45
import static com.codeborne.selenide.Selenide.$$;
56
import static com.codeborne.selenide.Selenide.$x;
@@ -17,6 +18,7 @@
1718
import io.kafbat.ui.screens.topics.enums.TimeToRetain;
1819
import io.kafbat.ui.utilities.WebUtil;
1920
import io.qameta.allure.Step;
21+
import org.openqa.selenium.Keys;
2022

2123
public class TopicCreateEditForm extends BasePage {
2224

@@ -32,7 +34,7 @@ public class TopicCreateEditForm extends BasePage {
3234
protected SelenideElement customParameterDdl = $x("//input[contains(@name, 'customParams')][@role='listitem']");
3335
protected SelenideElement deleteCustomParameterBtn = $x("//span[contains(@title, 'Delete customParam')]");
3436
protected SelenideElement addCustomParameterTypeBtn = $x("//button[contains(text(), 'Add Custom Parameter')]");
35-
protected SelenideElement customParameterValueField = $x("//input[@placeholder='Value']");
37+
protected SelenideElement customParameterValueField = $x("//label[text()='Value *']/..//input");
3638
protected SelenideElement validationCustomParameterValueMsg = $x("//p[contains(text(), 'Value is required')]");
3739
protected String ddlElementLocator = "//li[@value='%s']";
3840
protected String btnTimeToRetainLocator = "//button[@class][text()='%s']";
@@ -116,20 +118,27 @@ public TopicCreateEditForm setCustomParameterType(CustomParameterType customPara
116118

117119
@Step
118120
public TopicCreateEditForm clearCustomParameterValue() {
119-
WebUtil.clearByKeyboard(customParameterValueField);
121+
customParameterValueField.shouldBe(enabled).sendKeys(Keys.END);
122+
String value = customParameterValueField.getValue();
123+
int valueLength = value != null
124+
? value.length()
125+
: 0;
126+
for (int i = 0; i < valueLength; i++) {
127+
customParameterValueField.sendKeys(Keys.BACK_SPACE);
128+
}
120129
return this;
121130
}
122131

123132
@Step
124133
public TopicCreateEditForm setNumberOfPartitions(int partitions) {
125-
partitionsField.shouldBe(Condition.enabled).clear();
134+
partitionsField.shouldBe(enabled).clear();
126135
partitionsField.sendKeys(String.valueOf(partitions));
127136
return this;
128137
}
129138

130139
@Step
131140
public TopicCreateEditForm setTimeToRetainDataByButtons(TimeToRetain timeToRetain) {
132-
$x(String.format(btnTimeToRetainLocator, timeToRetain.getButton())).shouldBe(Condition.enabled).click();
141+
$x(String.format(btnTimeToRetainLocator, timeToRetain.getButton())).shouldBe(enabled).click();
133142
return this;
134143
}
135144

e2e-tests/src/main/java/io/kafbat/ui/utilities/WebUtil.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.kafbat.ui.utilities;
22

3+
import static com.codeborne.selenide.Condition.enabled;
34
import static io.kafbat.ui.variables.Common.LOG_RESULT;
45

56
import com.codeborne.selenide.Condition;
@@ -51,8 +52,13 @@ public static void clickByJavaScript(SelenideElement element) {
5152

5253
public static void clearByKeyboard(SelenideElement field) {
5354
log.debug("\nclearByKeyboard: {{}}", field.getSearchCriteria());
54-
field.shouldBe(Condition.enabled).sendKeys(Keys.END);
55-
field.sendKeys(Keys.chord(Keys.CONTROL + "a"), Keys.DELETE);
55+
field.shouldBe(enabled).sendKeys(Keys.PAGE_DOWN);
56+
Selenide.actions()
57+
.keyDown(Keys.SHIFT)
58+
.sendKeys(Keys.PAGE_UP)
59+
.keyUp(Keys.SHIFT)
60+
.sendKeys(Keys.DELETE)
61+
.perform();
5662
}
5763

5864
public static boolean isVisible(SelenideElement element, int... timeoutInSeconds) {

0 commit comments

Comments
 (0)