Find element that ID is generated randomly

0

I have a situation that the id always keeps updating randomly ... and without an apparent orderimpossible I use find_element_by_id

The component is as follows:

<table id="treeview-2234-record-879" data-boundview="treeview-2234" data-recordid="879" data-recordindex="0" class="x-grid-item x-grid-item-selected" cellpadding="0" cellspacing="0" style="width:100%;">

What have I tried?

  • Use the recordid, but it repeats itself in some cases
  • For class_name there are other components with the same class
  • Of course, by the id..which as I explained it refreshes throughout refresh and is random
  • I tried the element text, but without success.
  • At the root of treeview-2234, to no avail.

I'm another victim of EXT , some light?

    
asked by anonymous 18.01.2016 / 18:50

1 answer

1

As the implementation of selenium for python allows you to use CSS and XPATH selectors this is trivial, examples:

# XPATH

table = driver.find_element_by_xpath("//table[@data-recordid='879']")

# CSS

table = driver.find_element_by_css_selector("table[data-recordid='879']")
    
18.01.2016 / 19:30