I am trying to loop through different checkboxes and check them if the text is present in the list then click if not then move on.
the html element that I have been able to extract is below:
<label>
<input type ="checkbox" value = "pf29">
<span> BNN Bloomberg </span>
<span> class='count'>(16)</span>
<label>
when I do element.text it gives me BNN Bloomberg (16). Is there a way to restrict the text output to only BNN Bloomberg?
There are roughly 33 different tags so I cant use any of the string methods to limit the number of characters.
Fairly new to html and selenium so excuse my wording.
Currently this is what my code looks like
element_list = (driver.find_elements_by_css_selector("div[class='modal-dialog-padded-body'] label"))
source = element_list[3].text
print(source)
print(source) gives me BNN Bloomberg (16)
Edit: I have to loop through 21 different elements and look at the text to see what the source is and check the checkbox accordingly.