当前位置: 首页>>代码示例>>Java>>正文


Java WebElement.isDisplayed方法代码示例

本文整理汇总了Java中org.openqa.selenium.WebElement.isDisplayed方法的典型用法代码示例。如果您正苦于以下问题:Java WebElement.isDisplayed方法的具体用法?Java WebElement.isDisplayed怎么用?Java WebElement.isDisplayed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openqa.selenium.WebElement的用法示例。


在下文中一共展示了WebElement.isDisplayed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: waitForElementToAppear

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
/**
 * Wait for element to appear.
 *
 * @param driver the driver
 * @param element the element
 * @param logger the logger
 */
public static boolean waitForElementToAppear(WebDriver driver, WebElement element, ExtentTest logger) {
	boolean webElementPresence = false;
	try {
		Wait<WebDriver> fluentWait = new FluentWait<WebDriver>(driver).pollingEvery(2, TimeUnit.SECONDS)
				.withTimeout(60, TimeUnit.SECONDS).ignoring(NoSuchElementException.class);
		fluentWait.until(ExpectedConditions.visibilityOf(element));
		if (element.isDisplayed()) {
			webElementPresence= true;
		}
	} catch (TimeoutException toe) {
		logger.log(LogStatus.ERROR, "Timeout waiting for webelement to be present<br></br>" + toe.getStackTrace());
	} catch (Exception e) {
		logger.log(LogStatus.ERROR, "Exception occured<br></br>" + e.getStackTrace());
	}
	return webElementPresence;
}
 
开发者ID:anilpandeykiet,项目名称:POM_HYBRID_FRAMEOWRK,代码行数:24,代码来源:WebUtilities.java

示例2: visibilityOfNbElementsLocatedBy

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
/**
 * An expectation for checking that nb elements present on the web page that match the locator
 * are visible. Visibility means that the elements are not only displayed but also have a height
 * and width that is greater than 0.
 *
 * @param locator
 *            used to find the element
 * @param nb
 *            is exactly number of responses
 * @return the list of WebElements once they are located
 */
public static ExpectedCondition<List<WebElement>> visibilityOfNbElementsLocatedBy(final By locator, final int nb) {
    return new ExpectedCondition<List<WebElement>>() {
        @Override
        public List<WebElement> apply(WebDriver driver) {
            int nbElementIsDisplayed = 0;
            final List<WebElement> elements = driver.findElements(locator);
            for (final WebElement element : elements) {
                if (element.isDisplayed()) {
                    nbElementIsDisplayed++;
                }
            }
            return nbElementIsDisplayed == nb ? elements : null;
        }
    };
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:27,代码来源:Utilities.java

示例3: reActivateItem

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
@Step("Rreactivate the item")
public boolean reActivateItem(String itemName){
    WebElement todoItem = driver.findElement(By.xpath("//label[.='" + itemName + "']"));
    WebElement divClass = todoItem.findElement(By.xpath(".."));
    WebElement chkComplete = divClass.findElement(By.tagName("input"));
    chkComplete.click();
    WebElement liClass = null;
    try{
        liClass = divClass.findElement(By.xpath(".//*[@id='clear-completed']"));
        if (liClass.isDisplayed()){
            return false;
        }
    }catch (Exception e){
    }
    return true;
}
 
开发者ID:AdyKalra,项目名称:ToDoMVCEmberJS,代码行数:17,代码来源:BasicTodoMvcPage.java

示例4: waitFor

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
public static void waitFor(WebDriver driver, long timeout, By... elements) throws TimeoutException, InterruptedException {
	try {
		WaitUtil.waitFor(() -> elementsPresent(driver, elements), null, 1000L, timeout);
	} catch (TimeoutException ex) {
		try {
			for (By element : elements) {
				WebElement webElement = driver.findElement(element);
				if (!webElement.isDisplayed()) {
					throw new TimeoutException("Timeout exception during waiting for web element: " + webElement.getText());
				}
			}
		} catch (NoSuchElementException | StaleElementReferenceException x) {
			throw new TimeoutException("Timeout exception during waiting for web element: " + x.getMessage());
		}
	}
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:17,代码来源:DriverUtil.java

示例5: checkAllCheckBoxes

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
@Action(object = ObjectType.BROWSER, desc = "Check all the check boxes in the context")
public void checkAllCheckBoxes() {
    try {
        List<WebElement> checkboxes = Driver.findElements(By.cssSelector("input[type=checkbox]"));
        if (checkboxes.isEmpty()) {
            Report.updateTestLog(Action, "No Checkbox present in the page", Status.WARNING);
        } else {
            for (WebElement checkbox : checkboxes) {
                if (checkbox.isDisplayed() && !checkbox.isSelected()) {
                    checkbox.click();
                }
            }
            Report.updateTestLog(Action, "All checkboxes are checked", Status.PASS);
        }
    } catch (Exception ex) {
        Report.updateTestLog(Action, "Error while checking checkboxes - " + ex, Status.FAIL);
        Logger.getLogger(CheckBox.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:20,代码来源:CheckBox.java

示例6: handleCondition

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
public void handleCondition(String argumentShouldNotBeGiven
/**
 * No argument should be specifed Then only will be executed[show in
 * action column]
 */
) throws UnCaughtException {
    //Getting object from the object repository
    WebElement element = AObject.findElement("ObjectName", "PageName");
    //Putting condition on object
    if (element.isDisplayed()) {
        //Calling another test case if the condition is matched
        //Pass the Scenario name,Test case name and sub-iteration index
        executeTestCase("testscenario1", "cancelTicket", 1);
        Report.updateTestLog("Userdefined Action ", "inside reusable", Status.PASS);
        //If needed you can break the test case also by calling existing functions
        executeMethod("StopBrowser");
        //
    } else {
        Report.updateTestLog("Userdefined Action ", "switch to origional", Status.DONE);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:22,代码来源:SampleScript.java

示例7: testTryToAccessToStolenElement

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
@Test(enabled = false, expectedExceptions = StaleElementReferenceException.class)
public void testTryToAccessToStolenElement() {
    final WebElement stolenElement = givenStolenElement();
    final WebElement transformedStolenElement = transformer.apply(stolenElement);

    transformedStolenElement.isDisplayed();
}
 
开发者ID:WileyLabs,项目名称:teasy,代码行数:8,代码来源:FrameAwareWebElementTransformerTest.java

示例8: 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());
        }
    }
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:28,代码来源:SeleniumMultiValueEditor.java

示例9: 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);
    }
}
 
开发者ID:Nonorc,项目名称:saladium,代码行数:48,代码来源:SaladiumDriver.java

示例10: get

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
@Override
public Boolean get()
{
    WebElement element = elementSelector.get();

    return element != null && element.isDisplayed();
}
 
开发者ID:porscheinformatik,项目名称:selenium-components,代码行数:8,代码来源:SeleniumConditions.java

示例11: isVisible

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
/**
 * Check if an element is visible.
 *
 * @param selector Selector to find the element.
 * @return Return whether the element is visible or not.
 */
public boolean isVisible(By selector) {
    WebElement element = webDriver.findElement(selector);

    if (element == null) {
        return false;
    }

    return element.isDisplayed();
}
 
开发者ID:dvsa,项目名称:mot-automated-testsuite,代码行数:16,代码来源:WebDriverWrapper.java

示例12: elementsPresent

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
public static boolean elementsPresent(WebDriver driver, By... elements) {
	try {
		for (By element : elements) {
			WebElement webElement = driver.findElement(element);
			if (!webElement.isDisplayed()) {
				return false;
			}
		}
		return true;
	} catch (NoSuchElementException | StaleElementReferenceException x) {
		return false;
	}
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:14,代码来源:DriverUtil.java

示例13: isElementPresent

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
/**
 * Checks if is element present.
 *
 * @param driver the driver
 * @param element the element
 * @param logger the logger
 * @return true, if is element present
 */
public static boolean isElementPresent(WebDriver driver, WebElement element, ExtentTest logger) {
	boolean elementPresent = false;

	try {
		if (element.isDisplayed()) {
			elementPresent = true;
			logger.log(LogStatus.INFO, "WebElement is visible");
		}
	} catch (Exception e) {
		logger.log(LogStatus.ERROR, "WebElement is not present...<br></br>" + e.getStackTrace());
		e.printStackTrace();
	}
	return elementPresent;
}
 
开发者ID:anilpandeykiet,项目名称:POM_HYBRID_FRAMEOWRK,代码行数:23,代码来源:WebUtilities.java

示例14: scrollTo

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
/**
 * This method makes the driver scroll to the specified webelement in
 * browser
 **/
public static boolean scrollTo(WebElement wb, WebDriver driver) {
	try {
		JavascriptExecutor je = (JavascriptExecutor) driver;
		je.executeScript("arguments[0].scrollIntoView(true);", wb);

	} catch (Exception e) {
		e.printStackTrace();
	}
	return wb.isDisplayed();
}
 
开发者ID:AnujDasari,项目名称:Actitime-Framework,代码行数:15,代码来源:HelperManager.java

示例15: checkElementExists

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
@Override
public boolean checkElementExists(WebElement w) throws Exception{
	Assert.assertTrue(w.isDisplayed(), w.toString() + " is visible");
	return w.isDisplayed();
}
 
开发者ID:saiscode,项目名称:kheera,代码行数:6,代码来源:AbstractPage.java


注:本文中的org.openqa.selenium.WebElement.isDisplayed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。