本文整理汇总了Java中org.openqa.selenium.support.ui.Select.selectByVisibleText方法的典型用法代码示例。如果您正苦于以下问题:Java Select.selectByVisibleText方法的具体用法?Java Select.selectByVisibleText怎么用?Java Select.selectByVisibleText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openqa.selenium.support.ui.Select
的用法示例。
在下文中一共展示了Select.selectByVisibleText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setValue
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
/**
* select a value
*
* @param value the value to select
*/
@Override
@PublicAtsApi
public void setValue(
String value ) {
new RealHtmlElementState(this).waitToBecomeExisting();
try {
WebElement element = RealHtmlElementLocator.findElement(this);
Select select = new Select(element);
select.selectByVisibleText(value);
} catch (NoSuchElementException nsee) {
throw new SeleniumOperationException("Option with label '" + value + "' not found. ("
+ this.toString() + ")");
}
UiEngineUtilities.sleep();
}
示例2: createDocument
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
private boolean createDocument(String docType, String name) {
WebElement menu = openDocumentMenu();
// Find and click "Add new document" option
WebElement menuItem = menu.findElement(By.cssSelector("span[title='Add new document...']"));
menuItem.click();
// Wait for modal dialogue and find new document name field
WebElement nameField = helper.findElement(By.name("name-url:name"));
nameField.sendKeys(name);
// Choose document type
WebElement documentTypeField = getWebDriver().findElement(By.name("prototype"));
Select dropdown = new Select(documentTypeField);
dropdown.selectByVisibleText(docType);
// Confirm
clickButtonOnModalDialog("OK");
return isDocumentPresent(name);
}
示例3: selectOptionByText
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
/**
* Select option by option text.
*
* @param locator
* - element locator
* @param replacement
* - if element contains dynamic part, i.e. '$value' in locator
* part, then '$value' part will be replaced by replacement value
* @param optionText
* - dropdown option text
* @throws PropertyNotFoundException
* - throw this exception when declared locator is not found in
* object repository
* @throws InvalidLocatorStrategyException
* - throw this exception when locator strategy is wrong. Valid
* locator strategies are 'ID', 'XPATH', 'NAME', 'CSS_SELECTOR',
* 'CLASS_NAME', 'LINK_TEXT', 'PARTIAL_LINK_TEXT' and 'TAG_NAME'
*/
public void selectOptionByText(String locator, String replacement, String optionText)
throws PropertyNotFoundException, InvalidLocatorStrategyException
{
if (replacement != null)
{
if (locator.contains("$value"))
{
locator = locator.replace("$value", replacement);
}
}
element = ElementFinder.findElement(driver, locator);
Select dropdown = new Select(element);
dropdown.selectByVisibleText(optionText);
LOGGER.info("Successfully selected option '" + optionText + "' from element '" + locator
+ "' with locator value '" + props.getProperty(locator) + "'");
}
示例4: createOidcBearerClient
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Override
public String createOidcBearerClient(String clientName) {
try {
// .../auth/admin/master/console/#/create/client/foobar
driver.navigate().to(authUrl + "/admin/master/console/#/create/client/" + realm + "/");
DriverUtil.waitFor(driver, By.id("clientId"));
driver.findElement(By.id("clientId")).sendKeys(clientName);
driver.findElement(By.xpath("//button[contains(text(),'Save')]")).click();
DriverUtil.waitFor(driver, By.id("accessType"));
Select accessTypeSelect = new Select(driver.findElement(By.id("accessType")));
accessTypeSelect.selectByVisibleText(OpenIdAccessType.BEARER_ONLY.getLabel());
String clientId = driver.getCurrentUrl();
int lastSlash = clientId.lastIndexOf("/");
clientId = clientId.substring(lastSlash + 1);
driver.findElement(By.xpath("//button[contains(text(),'Save')]")).click();
return clientId;
} catch (InterruptedException | TimeoutException e) {
throw new IllegalStateException("Failed to ...", e);
}
}
示例5: selectByText
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Override
public boolean selectByText(Element element, String text)
{
Select select = createSelect(element);
if(select != null)
{
select.selectByVisibleText(text);
return true;
}
return false;
}
示例6: selectionner
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Override
public void selectionner(String type, String selector, String valeur) {
this.logger.info("selectionner(type" + type + ", selector" + selector + ", valeur" + valeur + ")");
try {
By locator = BySelec.get(type, selector);
WebElement elem = wait.until(ExpectedConditions.presenceOfElementLocated(locator));
String tagName = elem.getTagName();
if (tagName.equals("select")) {
Select select = new Select(elem);
// List<WebElement> options = select.getAllSelectedOptions();
// Iterator<WebElement> it = options.iterator();
// while (it.hasNext()) {
// WebElement webElement = it.next();
// if ("auto".equals(webElement.getCssValue("z-index"))) {
// if (!webElement.isDisplayed()) {
// System.out.println("################### !isDisplayed()");
// }
// System.out.println("################### cssValue " + webElement.getCssValue("z-index"));
// }
// }
select.selectByVisibleText(valeur);
// Thread.sleep(1000);
} else {
elem.click();
List<WebElement> children = elem.findElements(
By.xpath("//div[@class='listComboBoxElement']/li"));
Iterator<WebElement> it = children.iterator();
boolean flag = false;
do {
WebElement webElement = it.next();
if (webElement.getText().startsWith(valeur)) {
if (webElement.isDisplayed()) {
webElement.click();
flag = true;
}
}
} while (!flag && it.hasNext());
if (!flag) {
Assert.fail("Impossible de trouver la valeur :" + valeur
+ " pour le champs :" + type + ":" + selector);
}
}
} catch (NoSuchElementException | TimeoutException e) {
String pathScreenShot = takeScreenShot();
Assert.fail("Sélection impossible ! (type" + type + ", selector" + selector + ", valeur" + valeur + ") pathScreenShot=" + pathScreenShot);
}
}
示例7: selectOptionInField
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
/**
* Selects the specified option in the (dropdown/multi-select) field.
* @param optionText The text of the option to select
* @param label The field label
*/
public void selectOptionInField(String optionText, String label) {
// find the input associated with the specified label...
WebElement labelElement = webDriver.findElement(By.xpath("//label[contains(text(),'" + label + "')]"));
Select selectElement = new Select(webDriver.findElement(By.id(labelElement.getAttribute("for"))));
selectElement.selectByVisibleText(optionText);
}
示例8: createOicdConfidentialClient
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Override
public String createOicdConfidentialClient(String clientName, String rootUrl, List<String> redirectUri, String baseUrl, String adminUrl) {
try {
// .../auth/admin/master/console/#/create/client/foobar
driver.navigate().to(authUrl + "/admin/master/console/#/create/client/" + realm + "/");
DriverUtil.waitFor(driver, By.id("clientId"), By.id("rootUrl"));
driver.findElement(By.id("clientId")).sendKeys(clientName);
driver.findElement(By.id("rootUrl")).sendKeys(rootUrl);
driver.findElement(By.xpath("//button[contains(text(),'Save')]")).click();
DriverUtil.waitFor(driver, By.id("accessType"));
Select accessTypeSelect = new Select(driver.findElement(By.id("accessType")));
accessTypeSelect.selectByVisibleText(OpenIdAccessType.CONFIDENTIAL.getLabel());
DriverUtil.waitFor(driver, By.id("newRedirectUri"), By.id("rootUrl"));
driver.findElement(By.id("newRedirectUri")).sendKeys(redirectUri.get(0));
driver.findElement(By.id("baseUrl")).sendKeys(baseUrl);
driver.findElement(By.id("adminUrl")).sendKeys(adminUrl);
String clientId = driver.getCurrentUrl();
int lastSlash = clientId.lastIndexOf("/");
clientId = clientId.substring(lastSlash + 1);
driver.findElement(By.xpath("//button[contains(text(),'Save')]")).click();
return clientId;
} catch (InterruptedException | TimeoutException e) {
throw new IllegalStateException("Failed to ...", e);
}
}
示例9: createInsecureSamlClient
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Override
public String createInsecureSamlClient(String clientName, String masterSamlUrl, String baseUrl, List<String> redirectUris) {
try {
driver.navigate().to(authUrl + "/admin/master/console/#/create/client/" + realm + "/");
DriverUtil.waitFor(driver, By.id("clientId"));
driver.findElement(By.id("clientId")).sendKeys(clientName);
Select accessTypeSelect = new Select(driver.findElement(By.id("protocol")));
accessTypeSelect.selectByVisibleText(ProtocolType.SAML.getLabel());
driver.findElement(By.id("masterSamlUrl")).sendKeys(masterSamlUrl);
driver.findElement(By.xpath("//button[contains(text(),'Save')]")).click();
DriverUtil.waitFor(driver, By.id("baseUrl"), By.id("newRedirectUri"));
driver.findElement(By.xpath("//label[@for='samlServerSignature']/span/span[contains(@class, 'onoffswitch-active')]")).click();
driver.findElement(By.xpath("//label[@for='samlClientSignature']/span/span[contains(@class, 'onoffswitch-active')]")).click();
driver.findElement(By.id("baseUrl")).sendKeys(baseUrl);
driver.findElement(By.xpath("//button[contains(text(),'Save')]")).click();
for (String redirectUri : redirectUris) {
DriverUtil.waitFor(driver, By.id("newRedirectUri"));
driver.findElement(By.id("newRedirectUri")).sendKeys(redirectUri);
driver.findElement(By.xpath("//button[contains(text(),'Save')]")).click();
}
String clientUuid = driver.getCurrentUrl();
int lastSlash = clientUuid.lastIndexOf("/");
return clientUuid.substring(lastSlash + 1);
} catch (InterruptedException | TimeoutException e) {
throw new IllegalStateException("Failed to create saml client");
}
}
示例10: createOidcPublicClient
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Override
public String createOidcPublicClient(String clientName, String rootUrl, List<String> redirectUris, List<String> webOrigins) {
try {
// .../auth/admin/master/console/#/create/client/foobar
driver.navigate().to(authUrl + "/admin/master/console/#/create/client/" + realm + "/");
DriverUtil.waitFor(driver, By.id("clientId"), By.id("rootUrl"));
driver.findElement(By.id("clientId")).sendKeys(clientName);
driver.findElement(By.id("rootUrl")).sendKeys(rootUrl);
driver.findElement(By.xpath("//button[contains(text(),'Save')]")).click();
DriverUtil.waitFor(driver, By.id("accessType"));
Select accessTypeSelect = new Select(driver.findElement(By.id("accessType")));
accessTypeSelect.selectByVisibleText(OpenIdAccessType.PUBLIC.getLabel());
DriverUtil.waitFor(driver, By.id("newRedirectUri"), By.id("newWebOrigin"), By.id("rootUrl"));
driver.findElement(By.id("newRedirectUri")).sendKeys(redirectUris.get(0));
if (webOrigins != null) {
driver.findElement(By.id("newWebOrigin")).sendKeys(webOrigins.get(0));
}
String clientId = driver.getCurrentUrl();
int lastSlash = clientId.lastIndexOf("/");
clientId = clientId.substring(lastSlash + 1);
driver.findElement(By.xpath("//button[contains(text(),'Save')]")).click();
return clientId;
} catch (InterruptedException | TimeoutException e) {
throw new IllegalStateException("Failed to ...", e);
}
}
示例11: getOicdInstallationXmlFile
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Override
public String getOicdInstallationXmlFile(String clientId) {
try {
driver.navigate().to(authUrl + "/admin/master/console/#/realms/" + realm + "/clients/" + clientId + "/installation/");
DriverUtil.waitFor(driver, By.id("configFormats"));
Select configFormatSelect = new Select(driver.findElement(By.id("configFormats")));
configFormatSelect.selectByVisibleText(Provider.OIDC_JBOSS_XML_SUBSYSTEM.getWebUiLabel());
return driver.findElement(By.xpath("//textarea[contains(text(),'secure-deployment')]")).getText();
} catch (InterruptedException | TimeoutException e) {
throw new IllegalStateException("Failed to ...", e);
}
}
示例12: getSamlInstallationXmlFile
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Override
public String getSamlInstallationXmlFile(String clientId) {
try {
driver.navigate().to(authUrl + "/admin/master/console/#/realms/" + realm + "/clients/" + clientId + "/installation/");
DriverUtil.waitFor(driver, By.id("configFormats"));
Select configFormatSelect = new Select(driver.findElement(By.id("configFormats")));
configFormatSelect.selectByVisibleText(Provider.SAML_JBOSS_XML_SUBSYSTEM.getWebUiLabel());
return driver.findElement(By.xpath("//textarea[contains(text(),'<SingleSignOnService')]")).getText();
} catch (InterruptedException | TimeoutException e) {
throw new IllegalStateException("Failed to get saml installation file");
}
}
示例13: getJsonInstallationFile
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
@Override
public String getJsonInstallationFile(String clientId) {
try {
driver.navigate().to(authUrl + "/admin/master/console/#/realms/" + realm + "/clients/" + clientId + "/installation/");
DriverUtil.waitFor(driver, By.id("configFormats"));
Select configFormatSelect = new Select(driver.findElement(By.id("configFormats")));
configFormatSelect.selectByVisibleText(Provider.OIDC_KEYCLOAK_JSON.getWebUiLabel());
return driver.findElement(By.xpath("//textarea[contains(text(),'auth-server-url')]")).getText();
} catch (InterruptedException | TimeoutException e) {
throw new IllegalStateException("Failed to ...", e);
}
}
示例14: SelectVersion
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
public void SelectVersion(String version) {
Select select = new Select(selVersion);
select.selectByVisibleText(version);
}
示例15: SelectHardware
import org.openqa.selenium.support.ui.Select; //导入方法依赖的package包/类
public void SelectHardware(String hardware) {
Select select = new Select(selHardware);
select.selectByVisibleText(hardware);
}