Проблема заключается в следующем,пытаюсь автоматизировать позитивный тест на регистрацию пользователей.Первый тест проходит, а при следующем данные с dataProvider уже не подставляются и поля не чистятся. Тест проходит дальше почему то и уже вылетает ошибка что не может найти кнопку logOut.
Код
package UserRegistrarion;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class RegistraionUser {
WebDriver driver;
@DataProvider
public Object[][] testData() {
return new Object[][] { new Object[] { "Test", "0503332217", "qweqwe", "testemail1@gmail.com" },
new Object[] { "Test", "0663201232", "qweqwe", "testemail2@gmail.com" },
new Object[] { "Test", "0933201232", "qweqwe", "testemail3@gmail.com" },
new Object[] { "Test", "0633201232", "qweqwe", "testemail4@gmail.com" },
new Object[] { "Test", "0673201232", "qweqwe", "testemail5@gmail.com" },
new Object[] { "Test", "0963201232", "qweqwe", "testemail6@gmail.com" },
new Object[] { "Test", "0733201232", "qweqwe", "testemail7@gmail.com" }, };
}
@BeforeTest
public void setUp() {
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\1\\Downloads\\Q&A\\Автоматизация\\BrowserDrivers\\chromedriver_win32\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://can.ua/");
;
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@AfterTest
public void tearDown() {
driver.quit();
}
@Test(dataProvider = "testData")
public void DoRegistrationPositiv(String name, String phone, String password, String email)
throws InterruptedException {
HomePage home = new HomePage(driver);
home.callUpPopupXpath("//a[@name='signin']");
home.singUpbuttonXpath("//div[@class='text-wrap']//a[@name='dosignup']");
home.listOfInputs("//form[@name='signup-form']/div[@class='item']//input");
home.clearFields("//form[@name='signup-form']/div[@class='item']//input");
home.enterUserData(name, phone, password, email);
home.pressRegistrButton("//button[text()='регистрация']");
home.closePopupXpath("//a[@title='Закрыть']");
home.logOutXpath("//a[@name='signout']");
}
}
package UserRegistrarion;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class HomePage {
private WebDriver driver;
private String popup;
private String singUpButton;
private String registrationFields;
private List<WebElement> listOhFields;
private String regButton;
private String closePopupButton;
private String logOutButton;
public HomePage(WebDriver driver) {
this.driver = driver;
}
public void callUpPopupXpath(String p) {
this.popup = p;
driver.findElement(By.xpath(p)).click();
}
public void singUpbuttonXpath(String suButton) {
this.singUpButton = suButton;
driver.findElement(By.xpath(suButton)).click();
}
public void listOfInputs(String rf) {
this.registrationFields = rf;
listOhFields = driver.findElements(By.xpath(rf));
}
public void clearFields(String cf) {
this.registrationFields = cf;
listOhFields = driver.findElements(By.xpath(cf));
for (int i = 0; i < listOhFields.size(); i++) {
WebElement ele = listOhFields.get(i);
ele.clear();
}
}
public void enterUserData(String name, String phone, String password, String email) {
WebElement userName = listOhFields.get(0);
userName.sendKeys(name);
WebElement userPhone = listOhFields.get(1);
userPhone.sendKeys(phone);
WebElement userPass = listOhFields.get(2);
userPass.sendKeys(password);
WebElement userEmail = listOhFields.get(3);
userEmail.sendKeys(email);
}
public void pressRegistrButton(String rb) throws InterruptedException {
this.regButton = rb;
driver.findElement(By.xpath(rb)).click();
}
public void closePopupXpath(String cp) throws InterruptedException {
this.closePopupButton = cp;
WebElement ele = driver.findElement(By.xpath(cp));
ele.click();
}
public void logOutXpath(String lb) {
this.logOutButton = lb;
driver.findElement(By.xpath(".//*[@id='header-user-menu']/a/em")).click();
driver.findElement(By.xpath(lb)).click();
}
}
Ошибка вот такая org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element:
Версии ОС и софта следующие …