Skip to content

Commit

Permalink
Updating method name
Browse files Browse the repository at this point in the history
  • Loading branch information
raghavgarg1996 committed Oct 12, 2023
1 parent 809f712 commit e5d0ca2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/znsio/rpap/pages/BasePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public void inputDataToElement(By by, String dataToInput) {
String tagName = ele.getTagName();
scrollToView(by);
Map<String, Runnable> inputHandlers = new HashMap<>();
inputHandlers.put("select", () -> handleSelectInput(ele, dataToInput));
inputHandlers.put("textarea", () -> handleTextareaInput(ele, dataToInput));
inputHandlers.put("input", () -> handleTextInput(ele, dataToInput));
inputHandlers.put("select", () -> selectInputFromDropdown(ele, dataToInput));
inputHandlers.put("textarea", () -> enterTextInTextarea(ele, dataToInput));
inputHandlers.put("input", () -> enterTextInTextField(ele, dataToInput));
Runnable handler = inputHandlers.get(tagName.toLowerCase());
if (handler != null) {
handler.run();
Expand All @@ -34,18 +34,18 @@ public void inputDataToElement(By by, String dataToInput) {
}
}

private void handleSelectInput(WebElement element, String dataToInput) {
private void selectInputFromDropdown(WebElement element, String dataToInput) {
Select dropdown = new Select(element);
dropdown.selectByVisibleText(dataToInput);
}

private void handleTextareaInput(WebElement element, String dataToInput) {
private void enterTextInTextarea(WebElement element, String dataToInput) {
element.clear();
element.sendKeys(dataToInput);
element.sendKeys(Keys.TAB);
}

private void handleTextInput(WebElement element, String dataToInput) {
private void enterTextInTextField(WebElement element, String dataToInput) {
String inputType = element.getAttribute("type");

if (inputType.equals("text") || inputType.equals("email") || inputType.equals("password")) {
Expand Down

0 comments on commit e5d0ca2

Please sign in to comment.