Can't replicate Store Text, "...." not defined


#1

Hi guys, me again

Trying to replicate this code, but it does not seem to be working, have tried some variations, but no luck.

Keep getting the error code in red == not defined?


#2

Can you please post the macro source code here?


#3

Hi there, here you go

{
“Name”: “does not work”,
“CreationDate”: “2019-2-7”,
“Commands”: [
{
“Command”: “open”,
“Target”: “https://a9t9.com/”,
“Value”: “”
},
{
“Command”: “storeText”,
“Target”: “//*[@id=“content”]/div[3]/div/h2[1]”,
“Value”: “”
},
{
“Command”: “echo”,
“Target”: “Name var = ${name}”,
“Value”: “”
}
]
}

I have tried store and storeText can’t get either to work


#4

Before storeText, add

store | --- | name

so that the variable name is defined, even if the value does not exist on the page.


#5

Thanks I have tried that and it gives the same result

temper2342

{
“Name”: “temper – scrape and store from URL”,
“CreationDate”: “2019-2-7”,
“Commands”: [
{
“Command”: “open”,
“Target”: “https://a9t9.com/”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “—”,
“Value”: “name”
},
{
“Command”: “storeText”,
“Target”: “//*[@id=“content”]/div[3]/div/h2[1]”,
“Value”: “name”
},
{
“Command”: “echo”,
“Target”: “Name var = ${name}”,
“Value”: “”
}
]
}

each command works, but it breaks with

{
  "Command": "echo",
  "Target": "Name var = ${name}",
  "Value": ""
}

It is telling me the name is not defined, but we set that value twice. Also, since I copied this example from the documentation, I would have expected it work since it is as far as I can see the same thing.


#6

Trying to replicate the example from here

https://a9t9.com/kantu/docs/selenium-ide/storetext

Command Target Pattern/Text
open https://a9t9.com/
storeText //*[@id=“content”]/div[2]/div/h2[1] name
echo Name var = ${name}

#7

The locator in the demo code no longer works (page has changed), but after fixing this the demo macro works fine for me.

Output is: [echo] Name var = Visual Web Automation

Code:

{
  "Name": "1var",
  "CreationDate": "2019-2-8",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://a9t9.com/",
      "Value": ""
    },
    {
      "Command": "storeText",
      "Target": "//*[@id=\"content\"]/div[2]/div/div[1]/div[1]",
      "Value": "name"
    },
    {
      "Command": "echo",
      "Target": "Name var = ${name}",
      "Value": "green"
    }
  ]
}

#8

Thanks for trying

I copied that JSON code, created the script and same error as before, the demo locater is not where the error is being reported, as it says “[error] variable “NAME” is not defined” on the echo function - hmm – lol

soon as I run echo it changes to !STAUSOK == false


#9

Very mysterious… can you try the same macro in another Kantu, for example Kantu for Firefox?


#10

tested on my mac – works fine, but that’s another machine, not testing on FireFox :slight_smile:


#11

Hmm, It worked when I copied the JSON – well worked at one point, I am wondering if there is some kind of JavaScript Conflict with another app or something – I turned stuff off, but not luck as yet


#12

I have tried this super simple version too

“{
“Name”: “temper”,
“CreationDate”: “2019-2-12”,
“Commands”: [
{
“Command”: “open”,
“Target”: “https://a9t9.com/”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “12345”,
“Value”: “myvar”
},
{
“Command”: “echo”,
“Target”: “{myvar}", "Value": "" }, { "Command": "type", "Target": "id=phone", "Value": "{myvar}”
}
]
}”

basically the var here is pre-typed in as 12345 and even here I get [error]variable “MYVAR” is not defined


#13


#14

I can get the code to work on FF using the Kantu site, but it refuses, the same code does not work on the site I am using.

I can see it copies the var fine, I can see it sitting there, but can’t echo it out – any ideas?