EDIT: I figured out the culprit. That extra 's' certainly didn't do me any favors but the real issue was that I needed to switch to a new frame before searching for my element. Works like a charm now. Thanks for all the help!
I'm trying to pull the number of total results from various text searches in ServiceNow. I don't have access to the API so I'm having to brute force it a bit. Right now I have a python script that's using selenium to run the search. My problem is that for the life of me I can't scrape the results.
Here's the snippet of my code that isn't working:
elm_result = web_driver.find_elements_by_name("ts_count_8c58a5aa0a0a0b07008047e8ef0fe07d")
print("Total results: ", elm_result.text)
And here's the html and screenshot of the page it's pulling from:
<span name="ts_count_8c58a5aa0a0a0b07008047e8ef0fe07d" id="ts_count_8c58a5aa0a0a0b07008047e8ef0fe07d">
(162 matches)
<em>
<span class="search_no_results">No matches for <a title="" class="noresultlink" href="ticket_list.do sysparm_query=123TEXTQUERY321%3DSAP%5Eactive%3Dtrue">Tickets</a>
<span>
</span>
</span>
</em>
</span>
When I run the script it seems to hang on this last little before eventually throwing out the following error:
Traceback (most recent call last):
File "...", line 35, in <module> print("Total results: ", elm_result.text)
AttributeError: 'list' object has no attribute 'text'
I've tried attacking it from a bunch of different angles but nothing seems to work. My goal is to get the "162 results" text into a variable that I can then pass onto a csv.
find_element_by_name, rather thanfind_elements_by_namewhich return a List (List has no accribute 'text')