Find Xpath in Selenium

Asked

Viewed 2,038 times

4

I’m racking my brain to find the Xpath of a table. You could help me?

The structure is more or less like this:

 <div> 
  <div id="divMF">
   <iframe name="Principal>
     <frameset id="frmset">
       <frame name="corpo">
         <form name = "frmConsulta">
           <div id ="estrutura">
             <div id = "menos50">
               <div id = "idtable">

Could someone help me?

2 answers

5

If your idea is to get to the <div id = "idtable">, you can get there directly using just this:

//div[@id='idtable']
  • 1

    If it’s XHTML it could be up to //*[@id='idtable'] since id uniquely identifies the component.

1

Actually I needed to go to the frames before going to the div of the table. Stayed like this:

driver.switchTo().frame(driver.findElement(By.tagName("iframe")));
    driver.switchTo().frame(driver.findElements(By.xpath("//frameset[@id='frmSet']/*")).get(2));
    WebElement table = driver.findElement(By.id("idTable"));

Thanks to the people who helped!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.