/**
* This file is part of PaxmlSelenium.
*
* PaxmlSelenium is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PaxmlSelenium is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with PaxmlSelenium. If not, see <http://www.gnu.org/licenses/>.
*/
package org.paxml.selenium.webdriver;
import java.util.List;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.paxml.annotation.Util;
import org.paxml.core.Context;
import org.paxml.el.IUtilFunctionsFactory;
/**
* WebDriver utils.
*
* @author Xuetao Niu
*
*/
@Util("selenium")
public class WebDriverUtils implements IUtilFunctionsFactory {
public Object getUtilFunctions(Context arg0) {
return this;
}
/**
* {@inheritDoc}
*/
public Class<?> getXpathUtilFunctions(Context context) {
return null;
}
public static boolean equalString(Object obj, String str) {
if (obj == null) {
obj = "";
}
if (str == null) {
str = "";
}
return str.equals(obj.toString());
}
public static WebElement selectOne(WebDriver session, String selector) {
SelectableTag tag = new SelectableTag();
tag.setSession(session);
tag.setSelector(selector);
return tag.findElement(true);
}
public static List<WebElement> selectList(WebDriver session, String selector) {
SelectableTag tag = new SelectableTag();
tag.setSession(session);
tag.setSelector(selector);
return tag.findElements(true);
}
}