Java 获取表元素的旧值,如何获取新值?
我正试图从whoscored.com网站上搜集一些数据。() 我点击详细选项卡,按分钟对德国第二德甲球员进行排序。问题是,在单击这些选项卡并成功获取新表(第一个代码框)之后 celtext仍然提供初始表的值,即单击mins and detail选项卡之前的值。(第二段代码) 如何确保在检索文本时获得更新的信息 需要输出:Java 获取表元素的旧值,如何获取新值?,java,selenium,web-scraping,html-table,selenium-chromedriver,Java,Selenium,Web Scraping,Html Table,Selenium Chromedriver,我正试图从whoscored.com网站上搜集一些数据。() 我点击详细选项卡,按分钟对德国第二德甲球员进行排序。问题是,在单击这些选项卡并成功获取新表(第一个代码框)之后 celtext仍然提供初始表的值,即单击mins and detail选项卡之前的值。(第二段代码) 如何确保在检索文本时获得更新的信息 需要输出: 首先单击详细信息 点击分钟 第一个人应该是丹尼尔·霍勒·费尔南德斯 实际产出: 首次单击详细信息(成功) 单击分钟(玩家按分钟排序) 获取celtext(显示有关Philipp
WebElement detail=driver.findElement(By.xpath(“//*[@id=\”详细统计选项卡\“]/a”);//选择统计中的详细选项卡
executeScript(“参数[0]。单击();”,详细信息);
int ok_size1=driver.findElements(By.xpath(“//*[@id=\”播放器表统计头\“]]/tr/th[5]”)。size();//按分钟排序
driver.findElements(By.xpath(“//*[@id=\”播放器表统计头\“]/tr/th[5]”)。获取(确定大小1-1)。单击();
WebElement theTable=driver.findElement(By.xpath(“/*[@id=\“player table statistics body\”]);
Listrows\u table=table.findElements(按.tagName(“tr”));
rows\u count=rows\u table.size();
对于(int row=0;rowColumns\u row=rows\u table.get(row.findElements)(按.tagName(“td”);
int columns_count=columns_row.size();
for(int column=0;column
预期Daniel Heur Fernandes的输出,但获得Philipp Clement问题是在表中查找标记名为的元素。 相反,请尝试以下解决方案,以获取具有播放器链接的行元素列表
List<WebElement> players = driver.findElements(By.xpath("//*[@id='statistics-table-detailed']//tr//a[@class='player-link']"));
for(WebElement player:players)
{
System.out.println(player.getText());
}
List players=driver.findElements(By.xpath(“//*[@id='statistics-table-detailed']///tr///a[@class='player-link']);
for(WebElement播放器:播放器)
{
System.out.println(player.getText());
}
List<WebElement> players = driver.findElements(By.xpath("//*[@id='statistics-table-detailed']//tr//a[@class='player-link']"));
for(WebElement player:players)
{
System.out.println(player.getText());
}