How to Scrolldwon a web page using htmlunit or PanthomJS - java

I have a web page which continues to loading the contents when ONLY scrolling down the page.
So I want a way to scroll down the page pragmatically using HtmlUnit or PanthomJS.
Can I imitate the scroll down action(lets think using scroll element).
or
Can i imitate it using j script.
if this can do please explain the way.
Thanks.

You can set InnerHeight a large value. like this:
webClient.getCurrentWindow().setInnerHeight(60000);
the webcontrol will load all element,because of the webcontrol enough heigt.

Related

jquery: load/include html code into html file without delay?

I'm working on a mobile-app that uses cordova, so it's basically a html-website runing in an app. And I have a lot of elements and html-code that has to be present on all pages, e.g. navigation but also popups and so on and so on.
While working on larger webprojects I usually wrap these kind of code-segments in php-files and use "php include" to create my html file. Here however I can't work with php since there is no server. So since I would like to avoid having countless copies of the same code in every html-file, I'm looking for a way to include html code into an html file using jquery maybe?
I did try it with:
$("#includeContent1").load( "mod_navigation.html" );
and
$.get('mod_navigation.html', function(data) { $('body').append(data);});
Both worked, not as great as php, but did the trick. Problem is, the additional content (in this case the navigation) is being loaded "after" the parent html file is shown, making the navigation just pop up with a slight delay. This looks just horrible, because the navigation at the bottom of the screen just keeps flickering while using the app.
Is there a way to avoid these delays? Maybe by jumping to the new page AFTER everything in the html file has been loaded ... or any other way?
could you just try to create the whole DOM in a variable, and when all the HTML code is saved in the variable append it to the body? Say
$("body").empty(); // clear all
var content = "";
/* start to create content here */
$("body").append(content);
Althoug I have no idea how fast this is...
Cheers
You cannot use JavaScript that's on your page to preprocess that page's HTML as it is part of the document and therefore by definition executed after the document has been loaded.
You could however use a callback function to only display the new page after it has fully been loaded.

how do I find the end of the scroll bar using Java in RFT

My application has the web page, which is longer than the browser size. This needs the application shld be scrolled down to view the complete Web page. I need to know how do I find the end of the Web Page unsing Java in RFT code?
Is there some special object in your page footer? Like an image or a particular link? You can continue to scroll down until it becomes visible.
This is some sample code using LowLevelEvents, scrolling down with the mousewheel instead of dragging the scrollbar:
while(!your_object.isVisible()) {
LowLevelEvent llEvents[] = new LowLevelEvent[1];
llEvents[0] = MouseWheel(-25)
getRootTestObject().emitLowLevelEvent(llEvents);
}
Some docs: PlayingBackLowLevelMouseandKeyboardActions
If your_object.isVisible() always returns true, you can click on an object at the end of the page; this will browse the page to its and.
If there is no object clickable, you can press "END" to scroll to the end. Use browserObject.inputKeys method for this.

Anchor not working in IE7 via redirect (spring-mvc, jsp)

So for this project I am doing I have a page which generates content via clickable buttons. The button posts the form to my controller and the controller acts on the button that has been clicked. To show what was changed a redirect will occur (form in the session) with an anchor included. A little piece of javascript will then go to anchor which is in the link (eg. website/add/picture#123). This works fine in pretty much every browser except Internet Explorer 7.. I found out this has to do with an input field of file type.. Because if I remove the input field, then even IE7 will nicely scroll to the anchor..
Does anyone have any idea why this behaviour occurs?
If it's unclear please tell me and I'll provide more details..
Thanks a lot,
Davey
So.. I didn't manage to solve the input type=file bug.. I suppose it's just an IE7 bug. I made a work around to put the input field on a popup. A lot of overhead but it is working pretty well now

WebView Android application - how to read website content

Basically I am designing an webview app which would work something like this...
Pic Link : http://tinypic.com/r/2z9060n/6
I have made a webview browser application as shown in the pic. Now I want to define a mechanism using which I can crawl the webcontent and get content say marked in Red in the pic. Based on this content I wanna call another API which will show a message at the green box down.
Any help in the regard would be much appreciated.
Thanks
You can use a HTML parser such as Jsoup to parse the HTML page for the title / price of the item. Based on what the title and price are you can display a message using an overlay.
On a side note, the site is flipkart.com. You could also ask them if they have an API that they'd like to expose to you.

How to set webview area upon loading a link?

Ok so I have an rss reader that links to articles. One of the sites it links to doesn't have a mobile view. I was wondering if anyone knew if it was possible to set the "zoom" and position of the view once the page is loaded? So for instance if the following link were my article... http://www.neworleanssaints.com/news-and-events/article-1/Saints-agree-to-terms-with-7th-round-pick-Sean-Canfield/cce6a9ca-eaee-4878-ad40-0b98609f7fe7
Then how could I have the view focus on the article without the user having to zoom in and scroll the the top of the article. Thanks.
I think, you have to use an anchor, which are based on the ids of the HTML code. Then, you have to pass the Id you want to stick to after the url and a #.
With your example, it would give something like that :
http://www.neworleanssaints.com/news-and-events/article-1/Saints-agree-to-terms-with-7th-round-pick-Sean-Canfield/cce6a9ca-eaee-4878-ad40-0b98609f7fe7#c1256209263986
As the div you are looking for has an id (lucky you cause they don't have all the time)
<div id="c1256209263986" class="iw_component"><div xmlns:esi="http://www.edge-delivery.org
Hope this will help you (Try to click on the link I put, this should open the page at the start of the article.)
I never tried that but have a go a this, and come back to tell me if it worked.

Categories