當前位置: 首頁>>代碼示例>>Java>>正文


Java Select.selectByVisibleText方法代碼示例

本文整理匯總了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();
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:23,代碼來源:RealHtmlMultiSelectList.java

示例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);
    }
 
開發者ID:NHS-digital-website,項目名稱:hippo,代碼行數:23,代碼來源:ContentPage.java

示例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) + "'");
}
 
開發者ID:pradeeptaswain,項目名稱:oldmonk,代碼行數:38,代碼來源:BasePage.java

示例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);
	}
}
 
開發者ID:xtf-cz,項目名稱:xtf,代碼行數:26,代碼來源:SsoWebUIApi.java

示例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;
}
 
開發者ID:LinuxSuRen,項目名稱:phoenix.webui.framework,代碼行數:13,代碼來源:SeleniumSelect.java

示例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);
    }
}
 
開發者ID:Nonorc,項目名稱:saladium,代碼行數:48,代碼來源:SaladiumDriver.java

示例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);
}
 
開發者ID:dvsa,項目名稱:mot-automated-testsuite,代碼行數:12,代碼來源:WebDriverWrapper.java

示例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);
	}
}
 
開發者ID:xtf-cz,項目名稱:xtf,代碼行數:32,代碼來源:SsoWebUIApi.java

示例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");
	}
}
 
開發者ID:xtf-cz,項目名稱:xtf,代碼行數:38,代碼來源:SsoWebUIApi.java

示例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);
	}
}
 
開發者ID:xtf-cz,項目名稱:xtf,代碼行數:37,代碼來源:SsoWebUIApi.java

示例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);
	}
}
 
開發者ID:xtf-cz,項目名稱:xtf,代碼行數:15,代碼來源:SsoWebUIApi.java

示例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");
	}
}
 
開發者ID:xtf-cz,項目名稱:xtf,代碼行數:15,代碼來源:SsoWebUIApi.java

示例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);
	}
}
 
開發者ID:xtf-cz,項目名稱:xtf,代碼行數:15,代碼來源:SsoWebUIApi.java

示例14: SelectVersion

import org.openqa.selenium.support.ui.Select; //導入方法依賴的package包/類
public void SelectVersion(String version) {
    Select select = new Select(selVersion);
    select.selectByVisibleText(version);
}
 
開發者ID:mwinteringham,項目名稱:api-webdriver-harmony,代碼行數:5,代碼來源:EnterBugPage.java

示例15: SelectHardware

import org.openqa.selenium.support.ui.Select; //導入方法依賴的package包/類
public void SelectHardware(String hardware) {
    Select select = new Select(selHardware);
    select.selectByVisibleText(hardware);
}
 
開發者ID:mwinteringham,項目名稱:api-webdriver-harmony,代碼行數:5,代碼來源:EnterBugPage.java


注:本文中的org.openqa.selenium.support.ui.Select.selectByVisibleText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。