Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Ozhan Duz
    @ui4j
    skaros
    @skaros
    hi i posted this question on SO as well. I am trying to create a java application to automate a procedure on this site. I want to click on an item, with Id T:df6yt:0:jfcx6 but ui4j can not find it and i am getting an error. Thanks in advance
    Ryan Peterson
    @rpeterson03
    @ui4j Awesome project. I think I will be able to use your library in place of at leas two other libraries maybe three. I was hoping you(or someone with more experience) could help me with something. I am trying to load a page and then find images at potential x,y coordinates. I tried doing this by executing JS, but it kept coming back null. Then I found the "getElementFromPoint" in your API. I have tried to implement it with no luck. I was hoping you might have an example or could at least confirm that I am on the right path.
    Ozhan Duz
    @ui4j
    Hi @rpeterson03 I just commit sample test for getting image offset
    ui4j/ui4j@fdad275
    You could search all images by their offset
    let me know if this solution is not suitable for your case
    Ozhan Duz
    @ui4j
    You must call page.show() before using getElementFromPoint()
    Ryan Peterson
    @rpeterson03
    @ui4j that may actually work better than what I was doing. I was also not calling page.showI() so that's a good tip.
    Thankyou!
    Ryan Peterson
    @rpeterson03
    @ui4j I hit a snag. For my use case I am trying to get at logos on a web page and one of the problems is that logos are often set as css background images against an href. Wordpress.org is a good example. So the problem is that when I use .getDocument it is only returning the html which does not have reference to the css images. Ultimately I was hoping that by having the webkit render form I could get access to images in the final form by referencing the position. My logic being that i would be like right clicking and inspecting the element. Unfortunately I don't see clearly how I could reference an image like that. I could reference the href, but it's not clear how I would get at its calculated css to get the background-image attribute.
    Ozhan Duz
    @ui4j
    @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()); });
    }

    }```

    aleksey
    @lehins83
    This message was deleted
    aleksey
    @lehins83

    Hi, first of all thanks for great lib you provide. It really helps. But I have a question. I use ui4j for scrapping web pages with javascript generated content. So I need some browser. And I have url queue and processing it using ui4j. And looks like there is a memory leak. There are 3,102 instances of "com.sun.javafx.webkit.prism.WCImageDecoderImpl", and it occupies 1.5 GB of memory.

    Is this me who doing something wrong?

    Ozhan Duz
    @ui4j
    Hi @lehins83, that memory leak related with JavaFx
    I am going to publish workaround solution to solve that memory leak
    You need to checkout latest master branch (2.1.0-SNAPSHOT) to use the sample
    Let me know you if this sample enough to fix your memory leak problem
    aleksey
    @lehins83
    Hey, @ui4j thanks a lot it works. No leaking now!

    I have one more question.
    If I don't use browse.show() I just use

    String html = (String) page.executeScript("document.documentElement.innerHTML");

    to get page's html, do I really need to use "headless" mode?

    uPeekit
    @uPeekit
    Hey. Is there any way to use proxy in ui4j?
    Ozhan Duz
    @ui4j
    Hi @lehins83 headless mode is optional feature for continous build etc. you could optionally use page.show() or headless mode
    hi @uPeekit JavaFx WebKit browser use standard HttpUrlConnection, you could use standard Java http proxy settings: http://stackoverflow.com/questions/120797/how-do-i-set-the-proxy-to-be-used-by-the-jvm
    uPeekit
    @uPeekit
    @ui4j so I can just set system property, that's cool. thanks :)
    uPeekit
    @uPeekit
    what is the difference in using headless mode? seems the same for me if not call Page.show(), fx application launches anyway
    Ozhan Duz
    @ui4j
    @uPeekit headless mode could be used for ci build, command line (without window manager)
    bruce-genhot
    @bruce-genhot
    java.lang.ClassNotFoundException: com.sun.glass.ui.monocle.MonoclePlatformFactory
    Ozhan Duz
    @ui4j
    Hi @bruce-genhot do not forget to add monocle dependency to your pom file: <dependency>
    <groupId>org.jfxtras</groupId>
    <artifactId>openjfx-monocle</artifactId>
    <version>1.8.0_20</version>
    </dependency>
    Pat White
    @patwhite
    Anyone have time for a quick question about ui4j with scala, in headless mode? When I run page.captureScreen(outStream), I never get any bytes into the stream.
    But, I can get the html from the response.
    skaros
    @skaros

    hi @ui4j, could you help me with the NPE bug? i have ui4j v2.1.0 and Oracle Java 8U45, and i get NPE error on this
    System.setProperty("ui4j.headless", "true");
    BrowserEngine webkit = BrowserFactory.getWebKit();
    Page page = webkit.navigate(url);

    I just cant get it to work. Thank you

    Franz Allan Valencia See
    @franz-see
    How do you catch any javascript error?
    Franz Allan Valencia See
    @franz-see
    Is there a way for me to intercept all ajax requests done by ui4j?
    Franz Allan Valencia See
    @franz-see
    Re Javascript errors : ui4j/ui4j#68
    Igr Alexánder Fernández Saúco
    @alexfdezsauco
    Would be possible add a method to the page to load a complete document from an InputStream to be use in this way?
    BrowserEngine browser = BrowserFactory.getWebKit();
    Page page = browser.navigate("about:blank");
    page.loadFromStream(..);
    Tommaso Sotte
    @tomsotte
    Hi, how can i see the request/response of a page?
    vvicky72
    @vvicky72
    Two questions pls 1) Do I have any control over image format with captureScreen? Png/tiff/jpeg? 2) Currently I have to introduce Thread.sleep() after capture or else my image is blank. Can we make the captureScreen block until the image is written out? Help appreciated in advance !!
    Craig Combs
    @cdiddyPerformance
    Has this project been tested with web-sockets?
    Guerin
    @guillaumeguerin
    Hello everyone :)
    First of all, thanks for making such an awesome project !
    Does anyone know how can I use a proxy while navigating to a url with ui-4j ?
    momomo
    @momomo
    It doesn't seem as if navigating to http://username:password@url.com/ seems to be respected and instead we are navigating to the url without username and password. Is there a way around this?
    This would if not provided normally result in a popup alert box prompting for username and password but it is outside the html context.
    vojavocni
    @vojavocni
    Hi all, does anyone know if I can get source HTML from a webpage with ui4j?
    momomo
    @momomo
    Is it just me or does page.hide() and page.close() not work ?
    they cause future lag..
    it will close the window, but next dowload using the same engine wont
    kenrouzen
    @kenrouzen
    This message was deleted