使用 Selenium 和 Cucumber,我尝试设置一种方法来通过 args 存储 WebElements。然后使用第二种方法,我试图检查列表中所有元素的可见性。
我有一些元素是这样定位的:
@FindBy(how = How.XPATH, using = "//*
[@id=\"content\"]/section/fieldset/form/div[1]/div[2]/input")
public WebElement formName;
@FindBy(how = How.CSS, using = "//*
[@id=\"content\"]/section/fieldset/form/div[2]/div[2]/input")
public WebElement formPassword;
@FindBy(how = How.ID, using = "remember")
public WebElement rememberMe;
@FindBy(how = How.CLASS_NAME, using = "button principal")
public WebElement loginButton;
然后我写了这个方法来在列表中添加 WebElements:
public void crearListaWebElement(WebElement... elements){
List<WebElement> webElementList = new ArrayList<>();
for (WebElement element : elements){
webElementList.add(elements);
}
}
在 .add(elements) 1º 问题上出现此错误:
添加 (java.util.Collection) in List 不能应用于 (org.openqa.selenium.WebElement[])
无法弄清楚为什么我不能将这些相同类型的元素添加到我的列表中
然后,这是检查可见性的第二种方法:
public void estaVisible(WebDriver(tried WebElement as well) visibleWebElements) {
boolean esvisible = driver.findElement(visibleWebElements).isDisplayed();
Assert.assertTrue(esvisible);
return esvisible;
}
在“visibleWebElement”上收到此错误:
WebDriver 中的 findElement (org.openqa.selenium.By) 不能应用于 (org.openqa.selenium.WebDriver)
我了解 2 种不同类型的对象之间的冲突,但是,WebDriver 找到的对象不是存储为 WebElements 的吗?
有人可以在这里放一些灯吗?提前致谢。
斯蒂芬大帝
慕雪6442864
相关分类