如何从Selenium IDE中的'link'元素获取url

han*_*ano 6 ide url selenium hyperlink

我想在网页上获取(并存储到变量)一个超链接(链接)的URL.是否可以在Selenium IDE中获取它?

在我的测试中,我必须验证,如果链接存在,则从该链接存储URL并在测试中稍后使用它.

谢谢.

小智 8

driver.findElement(By.xxx).getAttribute('href');
Run Code Online (Sandbox Code Playgroud)


Mar*_*oma 6

虽然这个问题最初是针对 IDE 提出的,但我只是通过 Google 来这里搜索Python的相同答案。

上面那个给出

AttributeError: 'WebElement' object has no attribute 'getAttribute'
Run Code Online (Sandbox Code Playgroud)

因为对于 Python 来说是

driver.find_element(By.xxx).get_attribute('href')
Run Code Online (Sandbox Code Playgroud)


min*_*ret 1

是的,您可以简单地使用storeAttribute

如果你说你使用的是 Selenese 还是其他语言,我可以更明确。