seleniumxpathkatalon

How store href from an image xpath selenium ide ui vision katalon recorder


I want to store href url from an image but when i try it show error

This is the code

<a href="/mysite.com"><img src="//user/banners/16/08/1614708.gif" alt="AAA" data-tip="BBB" currentitem="false" class="" width="468" height="60"></a>

I want to store mysite.com

I already tried storeattribute with xpath and @href but show error (not available work for text link only)

Usually i use ui vision or katalon recorder but i never find a good solution at moment.

I need only xpath


Solution

  • Try this one out to get the parent a tag of the img src.

    print(driver.find_element_by_xpath("img[src='//user/banners/16/08/1614708.gif']//parent::a").get_attribute('href'))