Да, вы можете просто использовать список и хранить все ссылки.
У меня есть список многих гиперссылок по тексту ниже: Просмотр / Выбор мониторов. Поэтому я сохранил все ссылки просто в виде списка.
И затем я могу щелкнуть любую ссылку, передав нужное значение.
Если вы хотите нажать на все ссылки, тогда вы можетепросто используйте цикл for и щелкните по нему. Например:
List<WebElement> list = driver.findElements(By.linkText("View / Select Monitors"));
//Click on first hyperlink with matched text
list.get (0) .click ();
2-й пример:
Step1.[Getting all the links by tagname]
List<WebElement> allLinks = driver.findElements(By.tagName("a"));
Step2. [Storing the total size for the number of links]
int s =allLinks.size();
Шаг 3. [Я печатаю все ссылки здесь и там, положение]
for (int i = 0; iString txtlink = allLinks.get (i) .getText (); System.out.println("%n"+i);//Getting the value of i and hyperlink
System.out.println(txtlink);
allLinks.get(i).click
; // Вы можете просто передать значение i и щелкнуть по нему `Thread.sleep (2000) '}
In this way you can get the value of "i" also and then click if you like if you need to click on any particular link and if you want to click on all then simply use .click inside the loop.`enter code here`
Надеюсь, это поможет.