selenium 获取直接的子节点

 

Get all immediate children and nothing deeper

 


  
    

 

The expected result is div and span..

("*") gives all the child elements of the context node. So use:

WebElement body = browser.findElement(By.xpath("//body"));

body.findElement(By.xpath("*"));; // I want to get all child elements 
                                // inside body, but nothing deeper.

 

 

 

 

你可能感兴趣的:(selenium,java)