storeAttribute href error missing attribute href how store href from an image or link in a website?

Hi @admin @Plankton @ulrich @thecoder2012

I tried to store href in a simple image but give me an error I can store alt but not store href.

Ui vision can store href from images and links ?

Why alt working but href not working ?

I tried this demo but do not work.

https://ui.vision/rpa/docs/selenium-ide/storeattribute

Thanks for help.

My macro code

{
  "Name": "Store-href",
  "CreationDate": "2020-2-21",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://ui.vision/",
      "Value": ""
    },
    {
      "Command": "storeAttribute",
      "Target": "xpath=//*[@id=\"logo\"]/img@href",
      "Value": "mylink"
    },
    {
      "Command": "storeAttribute",
      "Target": "xpath=//*[@id=\"logo\"]/img@alt",
      "Value": "myalt"
    },
    {
      "Command": "echo",
      "Target": "The image links to ${mylink} and its ALT text is ${myalt}",
      "Value": ""
    }
  ]
}

Result

  • [status]

Playing macro Store-href

  • [info]

Executing: | open | https://ui.vision/ | |

  • [info]

Executing: | storeAttribute | xpath=//*[@id=“logo”]/img@href | mylink |

  • [error][ignored]

missing attribute ‘href’

  • [info]

Executing: | storeAttribute | xpath=//*[@id=“logo”]/img@alt | myalt |

  • [info]

Executing: | echo | The image links to ${mylink} and its ALT text is ${myalt} | |

  • [echo]

The image links to #LNF and its ALT text is UI Vision by a9t9 software - Image-Driven Automation

  • [info]

Macro completed (Runtime 4.12s)

1 Like

Have you tried css instead of xpath?

Yes i tried with simple link seem possibile to store href with image i can not.

I tried css xpath too with the same result.

The strange thing is the alt will be stored but href not recognized.

I hope an help, thanks

Thanks for reporting this. I moved the post from “howto” to “bug reports” :wink:

(logged as issue #699)

1 Like

It turns out this was a bug in the store Attribute documentation. The correct attribute to get the URL from an image (<IMG>) is @scr and not @href. Sorry about that.

This works:

{
  "Command": "storeAttribute",
  "Target": "xpath=//*[@id=\"logo\"]/img@src",
  "Value": "mylink"
},

PS: Note that @href will be correct for other objects, for example links!

1 Like

Thanks for information