I am trying to extract some attributes from an element on a website but I am getting Unable to find element error. The element doesn't have much info in it to search, apart from the attributes, and the one that I want will change every time.
I was initially converting the HTML to text and then regex searching the text to get what I want. Now I'm trying to make it a bit more elegant.
I have tried:
browser.find_element_by_name("Status")
to search text attribute (I know this is wrong)
browser.find_element_by_xpath("//label[@class='copySource']")
and a bunch of other variations
browser.find_element_by_xpath("//element[@attribute='Device Status:']")
plus some other stuff.
using this, with find all elements
, returned a blank list without an error.
browser.find_elements_by_xpath("//span[@class='class']")
The code I am trying to search:
<td>
<label class="copySource">Device Registration Status:</label>
</td>
<tr>
<td>
<label class="copySource">Device Status:</label>
</td>
<td>
<span class="copySource copyEndLine">operational</span>
</td>
</tr>
I am trying to extract the attribute in the last element, the word "operational" (this word changes). Getting error (or something similar to):
NoSuchElementException: no such element: Unable to locate element:
{"method":"xpath","selector":"//element[@attribute='Device Status:']"}