Created
December 4, 2024 15:43
-
-
Save borodicht/13036e210f2fee31041cb137e09b15d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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