[英]Xpath selenium finding elements
How can I get class="aaa34" using selenium and xpath?如何使用 selenium 和 xpath 获得 class="aaa34"?
client.Navigate().GoToUrl("*insert your URL here*");
IWEBELEMENT firstDiv = client.FindElement(By.XPath("//div[contains(@class,'__next')]"));
IWEBELEMENT secondDiv = firstDiv.FindElements(By.ClassName("jss1"));
This should do it.这应该这样做。 First I'm getting the parent div
enclosing the div
you want.首先,我让父div
包含您想要的div
。 That way I can get all the elements inside it, then filter what I want from it using the second IWEBELEMENT
variable.这样我就可以获取其中的所有元素,然后使用第二个IWEBELEMENT
变量从中过滤我想要的内容。 Let me know if it doesn't work.让我知道它是否不起作用。 There are other methods of selecting the div
that could work.还有其他选择可以工作的div
的方法。 :) :)
if your class is unique and doesn't change with page loading, try following.如果您的 class 是唯一的并且不会随着页面加载而改变,请尝试以下操作。 I can't test it at my end though.虽然我无法测试它。
chrome.find_elements_by_class_name("jss1945")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.