JavaScript Splash API/lua error: attempt to index local element (a nil value)

I'm writing a lua script that I want to use with scrapy + splash for a website. I want to write a script that enters a text and then clicks on a button. I have the following code:

function main(splash)
   local url = splash.args.url
   assert(splash:go(url))
   assert(splash:wait(5))

   local element = splash:select('.input_29SQWm')
   assert(element:send_text("Wall Street, New York"))
   assert(splash:send_keys("<Return>"))
   assert(splash:wait(5))

   return {
     html = splash:html(),
   }
end

Right now I'm using the splash API to test if my code runs properly. When I click "Render!" I get the following message:

{
  "info": {
      "message": "Lua error: [string \"function main(splash)\r...\"]:7: attempt to index local 'element' (a nil value)",
      "type": "LUA_ERROR",
      "error": "attempt to index local 'element' (a nil value)",
      "source": "[string \"function main(splash)\r...\"]",
      "line_number": 7
  },
  "error": 400,
  "type": "ScriptError",
  "description": "Error happened while executing Lua script"
}

So for some reason element is still nil when I try to send "Wall street, New York". I don't understand why; if I enter the following in chrome console:

$('.input_29SQWm')

I find the desired element!

Q: Does anyone know what I'm doing wrong?

Thanks in advance!

Answer:1

app.js var bodyParser = require('koa-bodyparser'); app.use(bodyParser()); app.use(route.get('/objects/', objects.all)); objects.js module.exports.all = function * all(next) { this.body = yield ...

app.js var bodyParser = require('koa-bodyparser'); app.use(bodyParser()); app.use(route.get('/objects/', objects.all)); objects.js module.exports.all = function * all(next) { this.body = yield ...

  1. query string with multiple parameters
  2. query string with spaces
  3. query string with array
  4. query string with #
  5. query string with no value
  6. query string with ampersand
  7. query string with filter in elasticsearch
  8. query string with multiple parameters in c#
  9. query string with special characters
  10. query string with forward slash
  11. query string with parameters
  12. query string with hash
  13. query string with post
  14. query string with slash
  15. query string with spaces c#
  16. query string with plus sign
  17. query string with anchor tag
  18. query string with multiple parameters in javascript

I want to display products unit of measurement at the frontend. For that I have created weight_unit attribute in admin panel and I am adding it to products like gram, kilogram, liter, etc. But I can't ...

I want to display products unit of measurement at the frontend. For that I have created weight_unit attribute in admin panel and I am adding it to products like gram, kilogram, liter, etc. But I can't ...

  1. product display unit
  2. display unit product buy
  3. retail product display unit/shelves
  4. portable product display unit

I have a function that returns JSON objects using hnews.getById(id). I then push each story returned in the promise to an array. I'm having trouble figuring out how I'd then get the complete array. Do ...

I have a function that returns JSON objects using hnews.getById(id). I then push each story returned in the promise to an array. I'm having trouble figuring out how I'd then get the complete array. Do ...

I am trying to understand why my SVG icon is not rendered correctly. The icon is a little smallest that my SVG element event if the viewBox property was used the same like width\height. Thanks for ...

I am trying to understand why my SVG icon is not rendered correctly. The icon is a little smallest that my SVG element event if the viewBox property was used the same like width\height. Thanks for ...

  1. max-width isn't working
  2. css width isn't working
  3. max-width isn't a valid css value