Skip to content

Instantly share code, notes, and snippets.

@borodicht
Created December 4, 2024 15:43
Show Gist options
  • Save borodicht/13036e210f2fee31041cb137e09b15d3 to your computer and use it in GitHub Desktop.
Save borodicht/13036e210f2fee31041cb137e09b15d3 to your computer and use it in GitHub Desktop.
package wrappers;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.time.Duration;
public class Picklist {
WebDriver driver;
WebDriverWait wait;
String label;
String pickListPattern = "//label[text()='%s']//ancestor::lightning-picklist";
public Picklist(WebDriver driver, String label) {
this.driver = driver;
this.label = label;
wait = new WebDriverWait(driver, Duration.ofSeconds(10));
}
public void select(String option) {
wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath(String.format(pickListPattern + "//button", label)))));
driver.findElement(By.xpath(String.format(pickListPattern + "//button", label)))
.click();
wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath(String.format(pickListPattern + "//lightning-base-combobox-item//span[text()='%s']",
label, option)))));
driver.findElement(By.xpath(String.format(pickListPattern + "//lightning-base-combobox-item//span[text()='%s']",
label, option))).click();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment