Using Selenium and Cucumber, I'm trying to set up a method to store WebElements through arguments. Then with a second method, I'm trying to check the visibility of all elements on the list.
I have some elements located this way:
@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;
Then I wrote this method to add WebElements in a list:
public void crearListaWebElement(WebElement... elements){
List<WebElement> webElementList = new ArrayList<>();
for (WebElement element : elements){
webElementList.add(elements);
}
}
I am getting this error on .add(elements):
add (java.util.Collection) in List cannot be applied to (org.openqa.selenium.WebElement[])
Cannot figure out why I can't add these same-type elements to my List
Also, here is the second method to check for visibility:
public void estaVisible(WebDriver(tried WebElement as well) visibleWebElements) {
boolean esvisible = driver.findElement(visibleWebElements).isDisplayed();
Assert.assertTrue(esvisible);
return esvisible;
}
I am getting this error on "visibleWebElement":
findElement (org.openqa.selenium.By) in WebDriver cannot be applied to (org.openqa.selenium.WebDriver)
I understand the conflict between the 2 different types of objects, but aren't the objects found by WebDriver stored as WebElements?
Could someone put some light on this question please? Thanks in advance.