本文整理匯總了Java中org.openqa.selenium.WebElement.getTagName方法的典型用法代碼示例。如果您正苦於以下問題:Java WebElement.getTagName方法的具體用法?Java WebElement.getTagName怎麽用?Java WebElement.getTagName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openqa.selenium.WebElement
的用法示例。
在下文中一共展示了WebElement.getTagName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: etreSelectionne
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
@Override
public void etreSelectionne(String type, String selector, String valeur) {
WebElement elem = this.findElement(BySelec.get(type, selector));
String tagName = elem.getTagName();
if (tagName.equals("select")) {
Select listProfile = new Select(elem);
if (!listProfile.getFirstSelectedOption().getText().equals(valeur)) {
Assert.fail("la valeur de l'élément ne correspond pas à la valeur " + valeur + "!");
}
} else {
WebElement item = elem.findElement(By.cssSelector("li > div > div:first-child()"));
if (!item.getText().equals(valeur)) {
Assert.fail("la valeur de l'élément ne correspond pas à la valeur " + valeur + "!");
}
}
}
示例2: getCellValue
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public HashMap<String, String> getCellValue(WebElement Element, int tr,
int td) {
int rowCounter = 0;
int colCounter = 0;
String rowKey = null;
String colKey = null;
HashMap<String, String> HashTable = new HashMap<>();
String strObj = Data;
List<WebElement> tableList = Element.findElements(By
.cssSelector("div[class='" + strObj + "'] tr td"));
for (WebElement listIterator : tableList) {
String TagName = listIterator.getTagName();
if (TagName.equals("tr")) {
rowKey = "R" + rowCounter++;
}
if (TagName.equals("td")) {
colKey = "C" + colCounter++;
}
HashTable.put(rowKey + colKey, listIterator.getText());
}
return HashTable;
}
示例3: setValue
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
@Override
public void setValue(Element ele, Object value)
{
ElementsSearchStrategy<WebElement> strategy = searchStrategyUtils.findElementsStrategy(WebElement.class, ele);
List<WebElement> eleList = strategy.searchAll(ele);
for(int i = 0; i < eleList.size(); i++)
{
WebElement webEle = eleList.get(i);
String tagName = webEle.getTagName();
String text = webEle.getText();
String attrName = null;
String attrValue = null;
if(!webEle.isDisplayed())
{
continue;
}
if(filter.filter(tagName, attrName, attrValue, text))
{
webEle.sendKeys(value.toString());
}
}
}
示例4: selectionner
import org.openqa.selenium.WebElement; //導入方法依賴的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);
}
}