mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-17 01:31:01 +00:00
Constand for background color added as well as a helper method to create
a XPath predicate which checks for style classes
This commit is contained in:
1 parent
c3483ae501
commit
cfed83ca10
2 files changed
+26
-1
No files matched your search
+2
@@ -7,4 +7,6 @@ public interface CSSConstants {
|
||||
public static final String CSS_STYLE_ATTRIBUTE_NAME = "style"; //$NON-NLS-1$
|
||||
|
||||
public static final String CSS_BACKGROUND_IMAGE = "background-image"; //$NON-NLS-1$
|
||||
|
||||
public static final String CSS_BACKGROUND_COLOR = "background-color"; //$NON-NLS-1$
|
||||
}
|
||||
+24
-1
@@ -6,7 +6,30 @@ import java.util.List;
|
||||
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
public class CSSHelper {
|
||||
public class CSSHelper {
|
||||
/**
|
||||
* <p>Creates an XPath 1.0 predicate that matches if an element has the given style sheet class in its "class"
|
||||
* attribute.</p>
|
||||
*
|
||||
* @param className
|
||||
* The name of the style sheet class to check for.
|
||||
* @return
|
||||
* An XPath predicate that matches if an element has the given style sheet class in its "class" attribute.
|
||||
*/
|
||||
public static String containsCSSClassPredicate(String className) {
|
||||
return "contains(concat(' ',normalize-space(@class),' '),' " + className + " ')";
|
||||
}
|
||||
|
||||
public static String containsCSSClassesPredicate(String... classNames) {
|
||||
StringBuilder builder = new StringBuilder(70 * classNames.length);
|
||||
|
||||
for(String className : classNames) {
|
||||
builder.append(containsCSSClassPredicate(className));
|
||||
builder.append(" and ");
|
||||
}
|
||||
return builder.substring(0, builder.length() - 5);
|
||||
}
|
||||
|
||||
public static List<String> getCSSClassNames(WebElement element) {
|
||||
String cssClasses = element.getAttribute(CSSConstants.CSS_CLASS_ATTRIBUTE_NAME);
|
||||
|
||||
|
||||
Reference in new issue
Block a user