Witam,
Staram się stworzyć test case przy użyciu Javay, Junit I Selenuim.
Założenie test casu jest przetestowanie navigacji na danej stronir. Osoba wprowadza link do strony głównej następnie wpisuje tytuły stron i tekst odoszacy się do linków które powinny przekierować do danej strony.
Posiadam już osobną klasę która zczytuje dane z pliku excel oraz pętlę do nawigacji.
Jednak pisanie pętli dla około 30 stron jest dosyć mozolne I wprowadza bałagan w kodzie.
Cześć kodu classy do odczytu danych z pliku (nie wrzycam wszystkiego bo trochę tych danych jest):

package data;

import (…)
public class CheckLinksData {
	String mainpage;
	String automainpage;
	String titlepage1;
	String titlepage2;
	String titlepage3;
	String titlepage4;

public CheckLinksData() {

		Workbook checklinks;

		try {
			checklinks = Workbook.getWorkbook(new File("src/buckupexcel/LookForText.xls"));

			Sheet check = checklinks.getSheet(0);
			Cell cell1 = check.getCell(12, 3);
			this.mainpage = cell1.getContents();
			Cell cell2 = check.getCell(10, 3);
			this.automainpage = cell2.getContents();
			Cell cell3 = check.getCell(2, 4);
			this.titlepage1 = cell3.getContents();
			Cell cell4 = check.getCell(2, 5);
			this.titlepage2 = cell4.getContents();
			Cell cell5 = check.getCell(2, 6);
			this.titlepage3 = cell5.getContents();
			Cell cell6 = check.getCell(2, 7);
			this.titlepage4 = cell6.getContents();
			Cell cell7 = check.getCell(2, 8);

		} catch (BiffException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public String getmainpage() {
		return this.mainpage;
	}
	public String getautomainpage() {
		return this.automainpage;
	}
	public String gettitlepage1() {
		return this.titlepage1;
	}
	public String gettitlepage2() {
		return this.titlepage2;
	}
	public String gettitlepage3() {
		return this.titlepage3;
	}
	public String gettitlepage4() {
		return this.titlepage4;
	}
}

Nawigacja po stronach:

[…]
	public CheckLinksData check = new CheckLinksData();
[…]
public void page1() {
		driver.get(check.getautomainpage());
		if (driver.getPageSource().contains(check.gettextpage1())) {
			if (check.getlookfortextpage1() != "") {				driver.findElement(By.linkText(check.getlookfortextpage1())).click();
			} else if (check.getidpage1() != "") {
				driver.findElement(By.id(check.getidpage1())).click();
			} else if (check.getclasspage1() != "") {
		driver.findElement(By.className(check.getclasspage1())).click();
			} if (check.getxpathpage14() != "") {
		driver.findElement(By.xpath(check.getxpathpage1())).click();
			} else if (check.gettextpage1() == "") {
				System.out.println("Empty cells");
			if (driver.getTitle().contains(check.gettitlepage1())) {
				System.out.println("Page title contains: " + check.gettitlepage1());
			} else {
				System.out.println("PAGE TITLE DOES NOT CONTAINS: " + check.gettitlepage1());
			}
		} else {
			System.out.println(" Page does not contains a link to a given page or item is not clickable: "
					+ check.gettitlepage1());
		}
	}

I tutaj pojawia się moje pytanie:
Czy da się stworzyć pętlę gdzie z klasy CheckLinksData() pętla nawigacji będzie pobierać dane zwiększając numer strony o jeden?