c# – 如何从selenium中的href链接获取属性值
发布时间:2020-12-15 06:35:42 所属栏目:百科 来源:网络整理
导读:我想从“a href”属性获取链接 a href="http://fgkzc.downloader.info/download.php?id=bc56585624bbaf29ebdd65d0248cb620" rel="nofollow" class="dl_link 1" style=""Download/a 我在做什么: ReadOnlyCollectionIWebElement lists1 = driver.FindElements
我想从“a href”属性获取链接
<a href="http://fgkzc.downloader.info/download.php?id=bc56585624bbaf29ebdd65d0248cb620" rel="nofollow" class="dl_link 1" style="">Download</a> 我在做什么: ReadOnlyCollection<IWebElement> 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"); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |