如果具有多级标题及其子标题的Web表也相同,如何在Selenium Web驱动程序中处理? SampleImage
const getAllProducts = this.sharedService.getData().pipe(
mergeMap(data=> from(data))
).pipe(
mergeMap(element =>
this.appService.getRest(AppConfig.settings.product.getProducts + '/' + element.product_obj_id).pipe(
map(res => res['data'])
)
),
combineAll()
)
`
答案 0 :(得分:0)
使用以下代码,您可以获得所有详细信息:
String P=driver.findElement(By.xpath("/html/body/table/tbody/tr[2]/th[1]")).getText();
String S = driver.findElement(By.xpath(“ / html / body / table / tbody / tr [2] / th [2]”))。getText();
String T = driver.findElement(By.xpath(“ / html / body / table / tbody / tr [3] / th”))。getText(); 字符串B = driver.findElement(By.xpath(“ / html / body / table / tbody / tr [4] / th”))。getText();
System.out.println(“ \ n” +“ ****** MARS详细信息*******” +“ \ n”);
for(int i = 3; i <= 4; i ++){
for(int j = 1; j <= 2; j ++){
WebElement x = driver.findElement(By.xpath(“ / html / body / table / tbody / tr [” + i +“] / td [” + j +“]”));
if(i==3 && j==1)
System.out.println(T+" "+P+" "+x.getText()+"\n");
else if(i==3 && j==2)
System.out.println(T+" "+S+" "+x.getText()+"\n");
else if(i==4 && j==1)
System.out.println(B+" "+P+" "+x.getText()+"\n");
else if(i==4 && j==2)
System.out.println(B+" "+S+" "+x.getText()+"\n"+"\n");
}
}
System.out.println(“ ****** VENUS Details *******” +“ \ n”);
for(int i = 3; i <= 4; i ++){
for(int j = 3; j <= 4; j ++){
WebElement x = driver.findElement(By.xpath(“ / html / body / table / tbody / tr [” + i +“] / td [” + j +“]”));
if(i==3 && j==3)
System.out.println(T+" "+P+" "+x.getText()+"\n");
else if(i==3 && j==4)
System.out.println(T+" "+S+" "+x.getText()+"\n");
else if(i==4 && j==3)
System.out.println(B+" "+P+" "+x.getText()+"\n");
else if(i==4 && j==4)
System.out.println(B+" "+S+" "+x.getText()+"\n");
}
}