如何从selenium中的href链接获取属性值
我试图从“a href”属性获取链接
Download
我在做什么:
ReadOnlyCollection lists1 = driver.FindElements(By.ClassName("dl_link")); string s = lists1[0].GetAttribute("a href");
我正在获取类“dl_link 1”的元素,但我无法得到它的链接,字符串为空?
您需要使用实际属性名称调用GetAttribute()
。 更换:
lists1[0].GetAttribute("a href");
有:
lists1[0].GetAttribute("href");
C#
element.GetAttribute("attribute name");
ruby
element.attribute("attribute name")
python
element.get_attribute("attribute name")
Java的
element.getAttribute("attribute name")