JavaSelenium获得以下兄弟

JavaSelenium获得以下兄弟,selenium,selenium-webdriver,xpath,selenium-chromedriver,Selenium,Selenium Webdriver,Xpath,Selenium Chromedriver,在第页中,我想访问游戏位置表: <h3><span class="mw-headline" id="Game_locations">Game locations</span></h3> <table class="roundy" style="margin:auto; border: 3px solid #A040A0; background: #78C850; pad

在第页中,我想访问游戏位置表:

 <h3><span class="mw-headline" id="Game_locations">Game locations</span></h3>
 <table class="roundy" style="margin:auto; border: 3px solid #A040A0; background: #78C850; padding:2px; width: 100%; max-width: 740px;">
但是,我不知道如何访问以下同级元素(表),我已尝试使用:

gameLocationsHeader.findElement(By.xpath("./following-sibling:*"));

但它不起作用,有什么提示吗?

与XPath匹配的节点是
span
。此元素不是
的同级元素。因此,您需要定位
h3
,它是
span
的父级和
表的同级

尝试以下代码行以获得所需结果:

gameLocationsHeader= driver.findElement(By.xpath("//h3[span='Game locations']"));
gameLocationsHeader.findElement(By.xpath("./following-sibling::table"));

XPath中有一个输入错误。尝试
/以下同级::*
我已经尝试过了,但是对于webelement next=gameLocationsHeader.findelelement(By.xpath(“/以下同级::*”),它不起作用;
gameLocationsHeader= driver.findElement(By.xpath("//h3[span='Game locations']"));
gameLocationsHeader.findElement(By.xpath("./following-sibling::table"));