1

I am working with Selenium and Python to automate a web service. I need to extract the text "test" from below, but am having difficulty figuring out how, or even if this is possible in selenium, or with a python library.

<label class="checkbox" for="checkbox1"data reactid=".0.1.0.1.$modal.$=10.0.1:1.5.1">
    before::
    "test"    
    ::after
</label>

Basically there is a checkbox and next to the checkbox displays the text in the pseudo-element. I am able to click on the checkbox, but I need to display the text to the user.

1 Answer 1

1

The .text should handle that:

driver.find_element_by_css_selector("label.checkbox").text
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @alecxe! I've been reading a lot of your posts to help me do this. That works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.