python - How to take info from particular amount of elements with the same class name? -


i have lot of tables on same screen. , need take tex 1 of simple example: table:phone

div id="phone_type" type-id="pass" class="panel panel-default sort_table">       <div class="panel-heading">         <h3 class="panel-title">phone</h3>       </div>       <ul class="list-group ui-sortable">                 <li class="list-group-item ui-sortable-handle" id="pass">       <div class="row">         <div class="col-md-8 col-xs-8 increase_padding">home</div>         <div class="col-md-2 col-xs-2 text-center">           <a data-remote="true" href="pass">edit</a>         </div>         <div class="col-md-2 col-xs-2 text-center">           <a data-remote="true" rel="nofollow" data-method="delete" href="pass">delete</a>         </div>       </div>     </li>             <li class="list-group-item ui-sortable-handle" id="pass">       <div class="row">         <div class="col-md-8 col-xs-8 increase_padding">work</div>         <div class="col-md-2 col-xs-2 text-center">           <a data-remote="true" href="pass">edit</a>         </div>         <div class="col-md-2 col-xs-2 text-center">           <a data-remote="true" rel="nofollow" data-method="delete" href="pass">delete</a>         </div>       </div>     </li>       </ul>      </form>       </div>     </div> 

table:condo

    <div id="condo_type" type-id="pass" class="panel panel-default sort_table">       <div class="panel-heading">         <h3 class="panel-title">condo</h3>       </div>       <ul class="list-group ui-sortable">                 <li class="list-group-item ui-sortable-handle" id="pass">       <div class="row">         <div class="col-md-8 col-xs-8 increase_padding">limited</div>         <div class="col-md-2 col-xs-2 text-center">           <a data-remote="true" href="pass">edit</a>         </div>         <div class="col-md-2 col-xs-2 text-center">           <a data-remote="true" rel="nofollow" data-method="delete" href="pass">delete</a>         </div>       </div>     </li>             <li class="list-group-item ui-sortable-handle" id="pass">       <div class="row">         <div class="col-md-8 col-xs-8 increase_padding">free</div>         <div class="col-md-2 col-xs-2 text-center">           <a data-remote="true" href="pass">edit</a>         </div>         <div class="col-md-2 col-xs-2 text-center">           <a data-remote="true" rel="nofollow" data-method="delete" href="pass">delete</a>         </div>       </div>     </li>       </ul> </form>   </div> </div> 

and need take text of col-md-8 col-xs-8 increase_padding

but problem when using:

table_content = driver.find_elements_by_css_selector('.col-md-8.col-xs-8.increase_padding') 

it takes info tables don't need. need take text 1 particular table. tables dynamic, can't take particular amount

table_content 

and append list. way address particular table , work outer html?

just make context-specific searches. e.g. if need element "phone type" table:

phone_type = driver.find_element_by_id("phone_type") print(phone_type.find_element_by_css_selector('.col-md-8.col-xs-8.increase_padding').text) 

or, in 1 go:

print(driver.find_element_by_css_selector('#phone_type .col-md-8.col-xs-8.increase_padding').text) 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -