Java tutorial
/* * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.iot.integration.ui.pages; import org.apache.commons.logging.Log; import org.openqa.selenium.By; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; /** * This class contains the constants and common methods used in pages. */ public class UIUtils { public static long webDriverTimeOut = 10; public static long webDriverTime = 60; public static int threadTimeout = 1000; public static boolean isElementPresent(Log log, WebDriver driver, By by) { try { WebDriverWait wait = new WebDriverWait(driver, webDriverTime); wait.until(ExpectedConditions.presenceOfElementLocated(by)); driver.findElement(by); return true; } catch (NoSuchElementException e) { log.error(by.toString() + " is not present"); return false; } } }