我想在网页上获取(并存储到变量)一个超链接(链接)的URL。是否可以在Selenium IDE中获取它?
在我的测试中,我必须验证,如果存在链接,则从该链接存储URL并在测试中稍后使用它。
感谢。
答案 0 :(得分:7)
driver.findElement(By.xxx).getAttribute('href');
答案 1 :(得分:4)
虽然这个问题最初是针对IDE提出的,但我刚刚通过Google搜索 Python 的相同答案。
上面给出了
AttributeError: 'WebElement' object has no attribute 'getAttribute'
因为对于Python来说是
driver.find_element(By.xxx).get_attribute('href')
答案 2 :(得分:0)
是的,您只需使用storeAttribute。
如果您说是否使用Selenese或其他语言,我可以更明确。