Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Java中如何By从对象中获取对象。WebElement
By
WebElement
我WebElement在不同的类中定义了一个,在测试计划中我想检查WebElement页面中是否可用。为了有一个更好的编码约定,我想避免硬编码By.
如果您必须在另一个类中使用 WebElement,则重用该元素的一种方法是将自身声明为静态元素:
public static WebElement element = driver.findElement(By.id("someId"));