Lua script - wrong CSS selector? "#tab-nav-main span:contains(desc)" - lua

I'm using Scrapy-splash but this question is about Lua script. I need to wait until one element is visible. The problem is that this element can be navigated only using it's text.
The equivalent XPATH is: //*[#id="tab-nav-main"]//span[text()="desc"]')
I tried:
#tab-nav-main span:contains(desc)
which works in chrome but not in lua
What would you do?
function main(splash, args)
splash:set_user_agent(args.ua)
assert(splash:go(splash.args.url))
local i=0
local maxwait=5
while not splash:select("#tab-nav-main span:contains(description)") do
if i==maxwait then
break --times out at maxwait secs
end
i=i+1
splash:wait(1) --each loop has duration 1sec
end
return {
html = splash:html(),
}
end
ERROR
2019-03-14 17:07:05 [scrapy_splash.middleware] WARNING: Bad request to Splash: {'description': 'Error happened while executing Lua script', 'error': 400, 'info': {'splash_method': 'select', 'line_number': 9, 'error': 'cannot select the specified element {\'js_error\': \'Error: SyntaxError: DOM Exception 12\', \'js_error_type\': \'SyntaxError\', \'js_error_message\': \'SyntaxError: DOM Exception 12\', \'type\': \'JS_ERROR\', \'message\': "JS error: \'Error: SyntaxError: DOM Exception 12\'"}', 'source': '[string "..."]', 'message': '[string "..."]:9: cannot select the specified element {\'js_error\': \'Error: SyntaxError: DOM Exception 12\', \'js_error_type\': \'SyntaxError\', \'js_error_message\': \'SyntaxError: DOM Exception 12\', \'type\': \'JS_ERROR\', \'message\': "JS error: \'Error: SyntaxError: DOM Exception 12\'"}', 'type': 'SPLASH_LUA_ERROR'}, 'type': 'ScriptError'}

Related

Getting "Parse Error" on JSON code - At a Loss How To Fix

Error Message From JSON Checker:
Parse error on line 1:
< script type = "app
^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
My code on line 1:
< script type = "application/ld+json" > {
I'm no coder or programmer, just trying to dress up my website with some JSON enhancements and can't seem to find out what's wrong with line 1. Can anybody help?
I've looked all over the web for an answer and my code on line 1 appears to be correct.
I don't know what's wrong...
Is JSON Checker an external JSON Validator? To use it just try to validate what is inside of the script HTML element because that is the JSON. For example:
<script type = "application/ld+json">
{"Hello":"World"}
</script>
In this case you have to validate:
{ "Hello":"World" }
I hope this helps.

Neo.ClientError.Procedure.ProcedureCallFailed: Failed to invoke procedure `apoc.do.when`: Caused by: org.neo4j.cypher.internal.v3_5.util.SyntaxExcepti

Can someone please help me with my probelm.
When i execute the below cypher query im getting exception as in the Title:
LOAD CSV WITH HEADERS FROM "file:///MNK/device.csv" AS line
MATCH (rSeq:Sequence{key:"runId_seq"})
OPTIONAL MATCH (l:Location{siteGaid:line.location_key}) WHERE NOT l:Model
WITH count(l) as i, line.location_key as key,line.location_key as sourceobjectId,
timestamp() as createdate,rSeq.runId as runId
CALL apoc.do.when(
i = 0,
'CREATE (a:locationServiceMigrationError
{errorCode: "missing_location",
errorDescription: "unable to find Location by its key",
matchingObjectKey: key,
srcObjectId: sourceobjectId,
type:"Location",
srcObjectName: "location_key",
sourceFileName: "device.csv",
scriptName:"device.cql",
createdDate:createdate,
runId:runId
}) RETURN a AS node',
'RETURN 0 AS result',
{key:key,
sourceobjectId:sourceobjectId,
createdate:createdate}
) YIELD value
RETURN count(value);
...Getting Error message like below
Neo.ClientError.Procedure.ProcedureCallFailed: Failed to invoke procedure apoc.do.when: Caused by: org.neo4j.cypher.internal.v3_5.util.SyntaxException: Variable runId not defined (line 11, column 11 (offset: 463))
...When i tried changing the 1st line with different file name as below then it is going fine.
LOAD CSV WITH HEADERS FROM "file:///MNK/location_coordinate_service.csv" AS line
.. Im not able to understand what exactly the issue is .
runId has to be passed into the parameter list too,
...,
{
key:key,
sourceobjectId:sourceobjectId,
createdate:createdate,
runId: runId
}

Continue script after rescue in ruby

I am parsing JSON output by using the curl mentioned below ,
However I am getting no method error while parsing the output due to DESCRIPTION #{h["incident_updates"][1]["status"] . because [["incident_updates"][1][status]] is not present in some cases, only the values of [["incident_updates"][0][status]] is available .
( But others iteration contains values for both [0][status]
[1][status] )
So to avoid the error used rescue method ,however error is prevented but script is not executing after the first error(iteration stopped on first error itself, script is not continuing ) . Need to run the script till the iteration completes (i.e., though no values present for [1] [status] script should run to bring the value for next iteration element because next element may contain [1] [status])
Please help on this .
Thanks in advance
def inc
begin
page3 = `curl https://api.statuspage.io/v1/pages/incidents.json?page=3 -H "Authorization: OAuth a8ef42"`
JSON.parse(page3).each do |h|
puts "ID : #{h["id"]} , CREATED AT : #{h["created_at"]} , LINK : #{h["shortlink"]} , ISSUE NAME : #{h["name"]} , DESCRIPTION #{h["incident_updates"][0]["status"]} , DESCRIPTION #{h["incident_updates"][1]["status"]}"
end
rescue NoMethodError => e
end
end
Try this:
def inc
page3 = `curl https://api.statuspage.io/v1/pages/incidents.json?page=3 -H "Authorization: OAuth a8ef42"`
JSON.parse(page3).each do |h|
begin
puts "ID : #{h["id"]} , CREATED AT : #{h["created_at"]} , LINK : #{h["shortlink"]} , ISSUE NAME : #{h["name"]} , DESCRIPTION #{h["incident_updates"][0]["status"]} , DESCRIPTION #{h["incident_updates"][1]["status"]}"
rescue NoMethodError => e
puts e
end
end
end
Explanation:
Whenever the exception is caught it tries to exit out of the block in which the exception has occurred.
In your previous code, you're handling it in the scope of the function. So, when the exception was occurring in the iteration it was exiting out of the loop because because it wasn't handled inside the scope in which it was occurring (loop) and was caught right outside the loop because you wrote it there (outside the loop).
To continue the iteration process you must handle it where it was occurring so that the system must know that it's been handled perfectly and it can perform the next iteration.

SAPUI5 / OpenUI5: Double Conditional binding in XML view

I would like to use conditional binding in my XML view but have two conditions, such as this:
visible="{= ${viewModel>/selectedTabKey} === 'aaa' && ${viewModel>/editMode} === true}"
This is equivalent to the example here (escaped "&&"!).
But when running this, I do get this error:
BindingParser-dbg.js:341 Uncaught (in promise) SyntaxError: Expected '}' and instead saw '' in expression binding {= ${viewModel>/editMode} === true at position 34
What am I doing wrong?
Cheers
The only point I see in your sample is that
${viewModel>/editMode} === true
is redundant and should be simplified to
${viewModel>/editMode}
BUT your error message seems to point elsewhere since it explicitly shows another code
{= ${viewModel>/editMode} === true
(which is not in your sample)

jsviews/jsrender Converter not working on {{:...}} tag

I am attempting to use a converter to modify a string in a jsrender template, but I can't seem to get the converter to work on a tag.
Using the example on JsRender API documentation Using converters for example, I have:
<script>
$.views.converters("upper", function(val) {
return val.toUpperCase();
});
</script>
Then in my HTML I have {{upper:Name}} which throws an error in the console: TypeError: val is undefined, and the template does not render at all.
However, if I apply the converter directly to a string like {{upper:"This should be uppercase"}} it outputs the string in uppercase as expected.
The {{:Name}} tag works fine by itself, so why isn't the converter working with it?
In case it is relevant, this is an ASP.NET-MVC project and the JSON data rendered by the template is coming from a $.post('#Url.Action(..,..)')... response. It's working perfectly until I attempt to apply the converter to the tag. Are converters not usable in this scenario?
It looks like your Name property is undefined in some case.
If you have a Name that is undefined, then {{:Name}} will render as the empty string, "" - but {{upper:Name}} will throw an error since undefined.toUpperCase() will fail.
You can investigate by breaking on thrown errors, (or by putting a break point or debugger statement in the converter) and seeing where your undefined Name is coming from.
You can also prevent the error getting thrown - and instead get error information rendered out - by any of the following techniques
write {{upper:Name onerror=true}} or {{upper:Name onerror='bad'}} (see https://www.jsviews.com/#onerror)
write
$.views.converters("upper", function(val) {
return val === undefined ? 'undefined' : val.toUpperCase();
});
write $.views.settings.debugMode(true);
and see what output you get, to investigate further about where your undefined Name is occuring.

Resources