Java tutorial
/* * Copyright (c) 2015 seleniumQuery authors * * Licensed 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 io.github.seleniumquery.by.css.pseudoclasses; import io.github.seleniumquery.by.xpath.component.ConditionSimpleComponent; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; /** * http://api.jquery.com/button-selector/ * * @author acdcjunior * @since 0.9.0 */ public class ButtonPseudoClass implements PseudoClass { private static final String INPUT = "input"; private static final String BUTTON = "button"; @Override public boolean isApplicable(String pseudoClassValue) { return BUTTON.equals(pseudoClassValue); } @Override public boolean isPseudoClass(WebDriver driver, WebElement element, PseudoClassSelector pseudoClassSelector) { return (INPUT.equals(element.getTagName()) && BUTTON.equalsIgnoreCase(element.getAttribute("type"))) || BUTTON.equals(element.getTagName()); } @Override public ConditionSimpleComponent pseudoClassToXPath(PseudoClassSelector pseudoClassSelector) { return new ConditionSimpleComponent( "[(" + "(self::input and translate(@type,'BUTTON','button') = 'button') " + "or " + "self::button" + ")]"); } }