These are chat archives for ui4j/ui4j

21st
Jul 2015
Ozhan Duz
@ui4j
Jul 21 2015 16:40
@rpeterson03 You could use Element.getCss(String) to find all links that have background-image css style

Sample code: ```package com.ui4j.sample;

import java.util.List;
import java.util.stream.Collectors;

import com.ui4j.api.browser.BrowserEngine;
import com.ui4j.api.browser.BrowserFactory;
import com.ui4j.api.browser.Page;
import com.ui4j.api.dom.Document;
import com.ui4j.api.dom.Element;

public class Sample {

public static void main(String[] args) {
    BrowserEngine webkit = BrowserFactory.getWebKit();
    Page page = webkit.navigate("http://ran.ge/2009/11/11/css-trick-turning-a-background-image-into-a-clickable-link/");

    Document document = page.getDocument();
    List<Element> links = document.queryAll("a");

    List<Element> linksWithBackgroundImage = links
                                                .stream()
                                                .filter(e -> e.getCss("background-image").isPresent())
                                                .collect(Collectors.toList());

    linksWithBackgroundImage.forEach(e -> { System.out.println(e.getCss("background-image").get()); });
}

}```