Sebastian Nielsen
Sebastian Nielsen

Reputation: 4199

python selenium - locating a text on a website, and storing it in a variable

https://gyazo.com/9f153457558977341c95019206010e00 This is the one text I want to store in a variable from the website. How do I do that? This is what I came up with:

text = browser.find_elements_by_css_selector('.vip-additional-text > *:nth-child(1) > p')
print(text)

output:

[]

It returns an empty list for some reason, can anyone help me please?

Upvotes: 1

Views: 591

Answers (1)

Moshisho
Moshisho

Reputation: 2951

If you want the text and not the webElement you should try:

text = browser.find_element_by_class_name("vip-additional-text").text

Upvotes: 1

Related Questions