I need to get the whole html code of a page which uses JavaScript. I use Selenium module with Chrome and see different 'find' methods, but didn't find some sort of ".document" property (like ie.document in VBA). Is there some possibility to get the whole result code (after JS execution) in string format for example?
Related
I have hundreds of page which I need to grab the urls of certain filehosters, but since the number of link for each page and the pages theyself, it has been tested to find the string and copy to the clipboard , using javascript
static getFileUrl(id){
var url=new URL("https://fileshosting.net/file/FileUrl")
url.searchParams.append('*',id)
return url.href
}
static copyFileUrl(id){
copy(this.getFileUrl(id))
}
I'm not to used to javascript but this should suffice, and everything it gets its the next console output
Uncaught SyntaxError: unexpected token: identifier
I understand this mean a semicolon before the statement is missing. But I don't get where it is. AFAIK there are two statement (the static procedures).
And sometimes there is only one url but in other pages there are 20 or 50 urls so perhaps it should be used an array, but I don't know how to implement an array in javascript.
so is there some method to, instead of open manually page to page, parse it from a terminal and pipe it to this (java)script or another language rutine?
Thanks in advance.
UPDATE
I have found another way, since it doesn't work this approach.
Thanks for the support and time.
I'm working on a power automate flow and I'm having some trouble. I copied some text to my clipboard in the flow and i asigned it to a variable in my flow. I'm trying to parse the variable using the javascript scripting feature but i'm getting a syntax error whenever I try to use the %variable% syntax in javascript. I used the variable button in the text editor they give you to add the variable to my script but even something simple as var res = %SimResults%; returns an error C:\Users\$me\AppData\Local\Temp\Robin\nkwrgcdoxrp.tmp(1, 11) Microsoft JScript compilation error: Syntax error
It seems that even though I Should be able to access my flow variables from Javascript it throws a syntax error when I try
You'll need to put quotes around it ...
var res = "%SimResults%"
... it treats the variables as more of a find and replace within your Javascript code, therefore, you need to do the work to ensure the correct encapsulation, etc. exists.
This may not solve your problem though depending on the complexity of what is contained within the variable.
If you have additional quotes, etc. you may need to escape them prior to putting them in the Javascript task IF they exist within the string ... just be mindful of that.
In controller class, I have added
model.addObject("hostname", hostname);
and tried to catch it in my jsp page with
var hostname=<%=request.getAttribute("hostname")%> ;
Yet, this is throwing error
Uncaught ReferenceError:**some_string** is not defined
What can be done to avoid this?
Remember: You are not passing a variable from one program to another, you are programmatically generating JavaScript source code from JSP.
some_string is a variable name, but not one you've declared, so you get a ReferenceError.
You need to generate the JS source code which gives you the result you need.
For most cases, due to the compatibility between JS and JSON, you can use a JSON stringifier to generate the source code that creates your values (this is a good generic solution as it will do The Right Thing with quotes, new lines, arrays, etc).
Be careful as if the string contains </script> you need to escape the / to prevent it terminating the <script> element. Some JSON serializers will do this by default. I don't know if Java's will.
So I am trying to iterate through JSON items via injected script. And BP is throwing me a syntax error that it is incapable of compiling my code.
code:
function fillInputs(json){
alert(json[0].Email);
}
through Invoke I am giving [JSON] variable that has a well structured JSON object which I created with help of Utility - JSON and it is working fine on test websites. But BP will not initialize specifically this part / alert(json[0].Email); / and is throwing a standard error which usually means syntax errors.
Could someone tell me if there is a better way to iterate through JSON objects with Blue Prism injected Javascript code and if I am choosing a harsh way to do it?
This is easily accomplished using the built-in Internet Explorer browser automation features provided out of the box in Blue Prism.
For organization, place your custom Javascript in a data item of type text on your action page:
Then use a Navigate stage to insert the fragment and invoke it:
With your current snippet, you'll get a nice alert window in Internet Explorer:
A good way to retrieve this data using Blue Prism would be to use the Javascript snippet you insert to create a hidden input element, the value of which is set a string representation of the JSON data you're attempting to exfiltrate.
You can then create a manual Application Modeler entry based off of an existing one to target this hidden element, and then use a Read stage to copy the data into a Data Item within Blue Prism. Further, you can use the bundled JSON object (or write your own as a wrapper around a better VB/C# library) to extract and manipulate the data within as you wish.
I often see in my code I am loading from my company's media central that jQuery is not available in the console normally. (No $ and jQuery)
But sometimes, to those elements to which jQuery is attached, it has a long number with it.
jQuery18306575689211022109_1378907534666
What is the purpose of doing this? Security?
Also, jQuery is sometimes available directly in the console, but only with the above numbers.
I am therefore unable to debug my apps in console, where I need to query using jQuery.
However, in the JavaScript code, jQuery is perfectly being used as $ and jQuery. So I apply a break-point and export as window.jQuery = jQuery.
Is this a proper way to debug the app, when jQuery is obfuscated?
UPDATE:
For eg., check this URL the app is calling. It seems that the URL knows what is the number appended to jQuery. How do I come to know of the same number while debugging? Any lights on what is going on?
It's a callback id automatically generated by jQuery. See the documentation for jsonpCallback.
It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling.
It seems that you are confusing two different variables. You can make a quick test on this website : http://www.jquery4u.com/function-demos/jsonp/#demo. Click "run demo", open Chrome's console, type "jQuery" in order to retrieve the callback's name, then perform this simple comparison :
jQuery16409391013463027775_1379048051365 === jQuery // false
That said, the fact that the variables named "$" and "jQuery" are not available in your case may be due to a specific implementation. One possibility could be the use of jQuery.noConflict() which allows either to customize the name used as a reference to jQuery, or to completely remove all references to jQuery from the global scope (window), so there is no way to access it in the console.