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
    ui4j/ui4j#24
    version 2.0 will be released at July 1
    rc183
    @rc183
    Hi. I try to use ui4j but when I launch my jar on ubuntu server 14.10, my browser object is null with the code : BrowserEngine browser = BrowserFactory.getBrowser(BrowserType.WebKit);
    You know why ?
    Ozhan Duz
    @ui4j
    Ui4j requires ui4j-all or ui4j-webkit jar. Most probably your classpath contains only ui4j-api.jar.
    Mike Markus
    @Waterstraal
    This might be a dumb question, but I can't find it anywhere, so I'll ask it here: Is it possible to open a page in certain dimension (width, height)? It appears that fullscreen is 1280x800
    Ozhan Duz
    @ui4j
    Hi @Waterstraal Yes, you could set the width and height of the window
    WebView view = (WebView) page.getView();
    view.getScene().getWindow().setWidth(200);
    view.getScene().getWindow().setHeight(200);
    Mike Markus
    @Waterstraal
    Works like a charm, thank you!
    Ozhan Duz
    @ui4j
    This message was deleted
    lagoonos
    @lagoonos
    Hi, I try to run ui4j within a JavaFX application to load webpage data in the background. I get a NullPointerException in com.ui4j.webkit.WebKitBrowser.run() in line 313 latch.countDown(); Any idea? Do I need to configure something when ui4j is running within a JavaFX application?
    Ozhan Duz
    @ui4j
    This message was deleted
    Hi @lagoonos Could you please share your sample code
    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?