org.openqa.selenium.support.ui.Select.escapeQuotes()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(205)

本文整理了Java中org.openqa.selenium.support.ui.Select.escapeQuotes()方法的一些代码示例,展示了Select.escapeQuotes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Select.escapeQuotes()方法的具体详情如下:
包路径:org.openqa.selenium.support.ui.Select
类名称:Select
方法名:escapeQuotes

Select.escapeQuotes介绍

暂无

代码示例

代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-support

/**
 * Select all options that display text matching the argument. That is, when given "Bar" this
 * would select an option like:
 *
 * <option value="foo">Bar</option>
 *
 * @param text The visible text to match against
 */
public void selectByVisibleText(String text) {
 StringBuilder builder = new StringBuilder(".//option[. = ");
 builder.append(escapeQuotes(text));
 builder.append("]");
 List<WebElement> options = element.findElements(By.xpath(builder.toString()));
 for (WebElement option : options) {
  option.setSelected();
  if (isMultiple()) {  return;  }
 }
}

代码示例来源:origin: org.seleniumhq.webdriver/webdriver-support

/**
 * Select all options that have a value matching the argument. That is, when given "foo" this
 * would select an option like:
 *
 * &lt;option value="foo"&gt;Bar&lt;/option&gt;
 *
 * @param value The value to match against
 */
public void selectByValue(String value) {
 StringBuilder builder = new StringBuilder(".//option[@value = ");
 builder.append(escapeQuotes(value));
 builder.append("]");
 List<WebElement> options = element.findElements(By.xpath(builder.toString()));
 for (WebElement option : options) {
  option.setSelected();
  if (isMultiple()) {  return;  }
 }
}

代码示例来源:origin: org.seleniumhq.webdriver/webdriver-support

/**
 * Deselect all options that display text matching the argument. That is, when given "Bar" this
 * would deselect an option like:
 *
 * &lt;option value="foo"&gt;Bar&lt;/option&gt;
 *
 * @param text The visible text to match against
 */
public void deselectByVisibleText(String text) {
 StringBuilder builder = new StringBuilder(".//option[. = ");
 builder.append(escapeQuotes(text));
 builder.append("]");
 List<WebElement> options = element.findElements(By.xpath(builder.toString()));
 for (WebElement option : options) {
  if (option.isSelected()) {
   option.toggle();
  }
 }
}

代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-support

/**
 * Select all options that have a value matching the argument. That is, when given "foo" this
 * would select an option like:
 *
 * &lt;option value="foo"&gt;Bar&lt;/option&gt;
 *
 * @param value The value to match against
 */
public void selectByValue(String value) {
 StringBuilder builder = new StringBuilder(".//option[@value = ");
 builder.append(escapeQuotes(value));
 builder.append("]");
 List<WebElement> options = element.findElements(By.xpath(builder.toString()));
 for (WebElement option : options) {
  option.setSelected();
  if (isMultiple()) {  return;  }
 }
}

代码示例来源:origin: org.seleniumhq.webdriver/webdriver-support

/**
 * Deselect all options that have a value matching the argument. That is, when given "foo" this
 * would deselect an option like:
 *
 * &lt;option value="foo"&gt;Bar&lt;/option&gt;
 *
 * @param value The value to match against
 */
public void deselectByValue(String value) {
 StringBuilder builder = new StringBuilder(".//option[@value = ");
 builder.append(escapeQuotes(value));
 builder.append("]");
 List<WebElement> options = element.findElements(By.xpath(builder.toString()));
 for (WebElement option : options) {
  if (option.isSelected()) {
   option.toggle();
  }
 }
}

代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-support

/**
 * Deselect all options that have a value matching the argument. That is, when given "foo" this
 * would deselect an option like:
 *
 * &lt;option value="foo"&gt;Bar&lt;/option&gt;
 *
 * @param value The value to match against
 */
public void deselectByValue(String value) {
 StringBuilder builder = new StringBuilder(".//option[@value = ");
 builder.append(escapeQuotes(value));
 builder.append("]");
 List<WebElement> options = element.findElements(By.xpath(builder.toString()));
 for (WebElement option : options) {
  if (option.isSelected()) {
   option.toggle();
  }
 }
}

代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-support

/**
 * Deselect all options that display text matching the argument. That is, when given "Bar" this
 * would deselect an option like:
 *
 * &lt;option value="foo"&gt;Bar&lt;/option&gt;
 *
 * @param text The visible text to match against
 */
public void deselectByVisibleText(String text) {
 StringBuilder builder = new StringBuilder(".//option[. = ");
 builder.append(escapeQuotes(text));
 builder.append("]");
 List<WebElement> options = element.findElements(By.xpath(builder.toString()));
 for (WebElement option : options) {
  if (option.isSelected()) {
   option.toggle();
  }
 }
}

代码示例来源:origin: org.seleniumhq.webdriver/webdriver-support

List<WebElement> options = element.findElements(By.xpath(".//option[. = " + escapeQuotes(text) + "]"));
for (WebElement option : options) {
 option.setSelected();
 } else {
  candidates = element.findElements(By.xpath(".//option[contains(., " + escapeQuotes(subStringWithoutSpace) + ")]"));

相关文章