foo: foo

How to find the value of an element using Splinter?

I have the following html fragment:

<p class="attrs"><span>foo:</span> <strong>foo</strong></p>
<p class="attrs"><span>bar:</span> <strong>bar</strong></p>
<p class="attrs"><span>foo2:</span> <strong></strong></p>
<p class="attrs"><span>description:</span> <strong>description body</strong></p>
<p class="attrs"><span>another foo:</span> <strong>foooo</strong></p>

I would like to get a body description using splinter. I managed to get the list pusing

browser.find_by_css("p.attrs")
+3
source share
3 answers
xpath = '//p[@class="attrs"]/span[text()="description:"]/following-sibling::strong'
description = browser.find_by_xpath(xpath).first.text
+6
source

Could you get a description using find_by_tag?

Find by tag

browser.find_by_tag('span')

Then go through all the "span" tags and find the value "description". I used the documentation here

+2
source

, , :

import selenium
from selenium import webdriver
driver = webdriver.Chrome('PATH_LOCATION_TO_CHROME_DRIVER') 
driver.find_elements_by_class_name("attrs")

, ! PATH_LOCATION_TO_CHROME_DRIVER --- chrome. Google, , Python.

-1

All Articles