如何使用硒在 ASP 来源中查找元素?

How to find elements in ASP sources using selenium?

<frame name="top" src="../LoginOrder/announcements.asp">
<frame name="bottom" src="../LoginOrder/menu_bar.asp" scrolling="no">

那两个框架中的内容只是 asp 源,所以我无法使用 selenium 的普通 FindElement 方法在这两个框架中找到元素。

有什么方法可以找到这些元素吗?

找到所需的框架并使用 switchTo() 切换到它。 Java 中的示例:

WebElement frame = driver.findElement(By.cssSelector("frame[src*=announcements]"));
driver.switchTo().frame(frame);

这里我们检查 announcements 文本是否存在于框架的 src 属性中。