Splash won't render all contents of page - splash-screen

I am using Splash v2.3.2 and I am trying to render a page but it is not rendering everything. It won't render images or dynamically loaded content.
I am using my http://localhost:8050/ with script:
function main(splash)
local url = splash.args.url
assert(splash:go(url))
assert(splash:wait(10))
return {
html = splash:html(),
png = splash:png(),
har = splash:har(),
}
end
Here is a browser rendering:
Here is a screenshot of the Splash rendering:
I have tried to change the wait time and also tried to allow plugins. None of this will work. I am assuming that the dynamically loaded content is being restricted but I am unsure. Any help is appreciated.

The problem is with localStorage - site uses it, but Splash uses Private Mode by default, and this disabls localStorage. To fix it, disable private mode (see here). This script works for me (Splash 3.0):
function main(splash)
splash.private_mode_enabled = false
local url = splash.args.url
assert(splash:go(url))
assert(splash:wait(10))
return {
html = splash:html(),
png = splash:png(),
har = splash:har(),
}
end
See also: http://splash.readthedocs.io/en/stable/faq.html#website-is-not-rendered-correctly

I'm assuming that you are trying to scrape property description text. In your code you have just added splash:wait(10), My suggestion is you should try and implement wait for a specific css element. In you case, span#listingpropertydescription.
You can write a function to wait for this particular element and then return the html page.
Note you can find a sample wait-for-element code in http://localhost:8050/
Hope this will help you

Related

It is possible to attach files by clicking on capybara

I'm using capybara, cucumber and webDriver to perform file tests
I am doing a study and need to attach a file, however the file input does not exist in the dom, and it is only created when the button is clicked, currently my code is like this:
HTML
<a id="input-id" href="#" onClick="callInput">Attach</a>
Script
function callInput(){
const input = document.createElement("input");
input.style.display = "none";
input.type = "file";
input.click();
}
If it's possible the only way would be using the attach_file block mode
attach_file('/file/to/be/attached') do
click_link('Attach')
end
Since you're setting display to 'none' rather than hiding via setting it offscreen or other methods it's possible the make_visible option could make it work if the above doesn't
attach_file('/file/to/be/attached', make_visible: true) do
click_link('Attach')
end
If neither of those work then it's not possible for Capybara to work with the way you've implemented file upload on your page.
Note: odds of either working is pretty low because you're never actually attaching the input to the page so events won't get routed anywhere Capybara can detect.

Selenium iframe selection issue

I'm testing our website login sequence with selenium. When I click login it loads an iframe, and the iframe id value changes each time it is loaded. So the test case fails in selenium.
What is the the command to read only the dynamic part of the iframe and locate it during the test run?
try this for capturing the popup,
String parentWindowHandle = browser.getWindowHandle(); // save the current window handle.
WebDriver popup = null;
Iterator<String> windowIterator = browser.getWindowHandles();
while(windowIterator.hasNext()) {
String windowHandle = windowIterator.next();
popup = browser.switchTo().window(windowHandle);
}
Hope it will helpful to you
Use FrameIndex to switch iframes.
driver.switchTo().frame(1);
or use xpath
driver.switchTo().frame(webElement)
Or share Html Code so we can give a better solution.

Launching a webpage in browser from an Adobe Air app not working

I've got a webpage I want to hook in to my Adobe Air app. It's running JavaScript, so I can't open it in the app, but I'm trying to launch it in the default system browser.
Here's the code that's supposed to be launching the page:
public function beginModule():void {
var loader:HTMLLoader = new HTMLLoader();
var gameURL:URLRequest = new URLRequest("file:///path/to/file.html");
loader.navigateInSystemBrowser = true;
loader.load(gameURL);
}
I've also tried using
flash.net.navigateToURL(gameURL);
but that had no effect.
Every time I hit the above method, that block executes but nothing happens other than a quick cursor change-- no browser opened, no change in the app. What am I missing here?
Before you start, check if the HTML page is properly running in the browser.
To open a HTML page in flex, use the HTML tag: <mx:HTML></mx:HTML>
Something like this: https://snipt.net/anishnair/flex-show-html-page/?key=28838d54ac287180032dee000ce33a74
Thank you.
Regards,
Anish
Simply use :
navigateToURL(url,"_blank");
to navigate to the url in the web-browser.

Disable copying data from webpage

I was looking for any way to create web page,so that user wont be able to copy content from my web page. i.e. User wont be able to select the any text present on the webpage.
Let's assume i am working on asp.net
Any interesting ideas to accomplish the task ?
Ultimately you can't.
If you disable the ability to select text, the context menu or even just the copy option from the context menu users will still be able to see your content.
If they can see it they can copy it:
Take a screenshot.
Take a photo.
Type the text they see into Notepad.
Dictate the text into a recorder.
It's not worth the development effort and you won't stop the determined copier. All you'll end up doing is annoying your legitimate users.
Add value to your site so people want to keep coming back rather than just taking content and running. This could be:
Allow user generated content to expand on what's there.
Update content regularly so it's always fresh.
You can use user-select CSS3 propertie
HTML like this :
<span class="protected">Datas you wants protect</span>
And the correspondant CSS :
.protected {
-moz-user-select:none;
-webkit-user-select:none;
user-select:none;
}
See my example : http://jsfiddle.net/DoubleYo/RPv4q/
This solution is not cross browser but work fine with firefox and chrome/safari
EDIT : advanced user can copy your content with view the page source, make pdf or print your page, and some people mention firebug, fiddler.
If you send down any text the user will be able to see the source, so disabling copy and paste by any method will not really help stop the determined copier.
The most effective approach would be to render your text in to an image on the server and send down the image and not the raw text, but before you do that there are several downsides to consider: 1) You will require capacity on your server to generate the image. 2) The data load will be higher than just text and compresion will be less effective. 3) You may also loose some caching options.
Is there a particular reason you don't want the user to copy the text, perhaps if you can provide more details other approaches may be possible?
Try this
<html>
<head>
<script language="<strong class="highlight">javascript</strong>">
function onKeyDown() {
// current pressed key
var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();
if (event.ctrlKey && (pressedKey == "c" ||
pressedKey == "v")) {
// <strong class="highlight">disable</strong> key press porcessing
event.returnValue = false;
}
} // onKeyDown
</script>
</head>
<body>
<form name="aForm">
<input type="text" name="aText" onkeydown = "onKeyDown()">
</form>
</body>
</html>
When someone visits your website they receive the html/css/images/JavaScript that makes up the bulk of your site. So they already have your Content, as most browsers cache this too, to allow quicker browsing.
Read more on HTTP here - http://www.http.header.free.fr/http.html
So it is not quite possible to totally stop anyone that know how the http protocol works. But what you can do is to maybe listen for right clicks and stop normal end users from right clicking and saving a image etc. You can get a snippet here - http://www.dynamicdrive.com/dynamicindex9/noright.htm
But if you are talking about protecting images/files that are selling please have a look at Protect html/php/image files from tracking as it then applies to your problem.
You can add to your body tag like so:
<body onselectstart="return false">
This is Internet. You can't completely protect the content of the page.
But you can difficult this task for the user.
You can too handle keyboard and mouse inputs, like Ctrl+C or right click of the mouse.
But remember that the user can always see the source code of the page, copy it and paste on a HTML editor.
You can make your site in Silverlight or Flash, but this will "disable" search engines indexing.
convert your page into a image
You can disable the selection, and with out selection you do not have copy/paste, however I suggest do that only on some parts of your page because is frustrate for the user.
This is the simple code that you can do that, eg, if you have a div with id="notme", run the disableSelOnThis("notme");
function disableSelOnThis(IdName) {
var oElem = document.getElementById(IdName);
if (oElem)
disableSelection(oElem); }
function disableSelection(element) {
element.onselectstart = function() {
return false;
};
element.unselectable = "on";
element.style.MozUserSelect = "none";
element.style.cursor = "default";
}
The code was from : http://ajaxcookbook.org/disable-text-selection/ , but its seams that this site is not longer live.
Of course without javascript enable this is not working and everything ChrisF says still stands.
Just copy and Paste the below javascript in your webpage:
<script language="javascript" type="text/javascript">
function disableselect(e) {
return false
}
function reEnable() {
return true
}
document.onselectstart = new Function("return false")
if (window.sidebar) {
document.onmousedown = disableselect // for mozilla
document.onclick = reEnable
}
function clickIE() {
if (document.all) {
(message);
return false;
}
}
document.oncontextmenu = new Function("return false")
var element = document.getElementById('tbl');
element.onmousedown = function () { return false; } // mozilla
</script>
Note:If the above code not works for Firefox then add style="-moz-user-select:none" in the body tag which needs to be restricted alongwith the above code.

Setting Page Title from a SWF

Is it possible to set the title of a page when it's simply a loaded SWF?
This is how I would do it:
ExternalInterface.call("document.title = 'Hello World'");
Or more generalized:
function setPageTitle( newTitle : String ) : void {
var jsCode : String = "function( title ) { document.title = title; }";
ExternalInterface.call(jsCode, newTitle);
}
Sure. This should fix you up:
getURL('javascript:var x = (document.getElementsByTagName("head")[0].getElementsByTagName("title")[0].firstChild.nodeValue = "This is a test!");');
Just replace "This is a test!" with your new title.
I would think you would be able to do it. You would have to access the javascript DOM.
A couple links that may steer you down the correct path..
http://homepage.ntlworld.com/kayseycarvey/document2.html
http://www.permadi.com/tutorial/flashjscommand/
You could use SWFAddress, it has a setTitle method. Plus, you get the added benefit of beng able to modify the URL for deep-linking.
EDIT: This won't work if the SWF is loaded directly in the browser, only if it is embedded in HTML.
I came up with the same problem of setting up the title of my page. Madw hell lot of efforts from downloading aspFlash controls to those swfObject....
Finally my team lead came up the solution....
open the pop of one page and in that page use one IFrame and use the Iframe to load the swf file.
So there are 2 page outer one is our control so just set the title.. inner one is the Iframe which is just another page so load the swf file directly by setting the scr="file path"

Resources