Metode 1: Udtræk via ID'er
// Udtræk en specifik celle
var cell = driver.FindElement(By.Id("p111")).Text;
// Udtræk en hel række
var row1 = Enumerable.Range(1, 9)
.Select(i => driver.FindElement(By.Id($"p11{i}")).Text)
.ToList();
Metode 2: Udtræk via Table Structure
// Udtræk alle rækker
var rows = driver.FindElements(By.CssSelector("tr[id^='p1']"));
// Udtræk alle celler i en række
foreach (var row in rows) {
var cells = row.FindElements(By.TagName("td"))
.Select(td => td.Text)
.Where(text => !string.IsNullOrEmpty(text))
.ToList();
}
Metode 3: Komplet Plade Udtræk
var bankoPlade = new int[3,9];
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= 9; j++) {
var cellId = $"p1{i}{j}";
var cellText = driver.FindElement(By.Id(cellId)).Text;
if (!string.IsNullOrEmpty(cellText)) {
bankoPlade[i-1,j-1] = int.Parse(cellText);
}
}
}
Datastruktur for bankoplader
class BankoPlade {
public string ID { get; set; }
public int[,] Tal { get; set; }
public bool[] RækkeStatus { get; set; }
public BankoPlade(string id) {
ID = id;
Tal = new int[3,9];
RækkeStatus = new bool[3];
}
}