Skip to content

How do I determine text visibility in multiple elements #1431

Answered by mdmintz
chenqinggang001 asked this question in Q&A
Discussion options

You must be logged in to vote

Use the TAG:contains(TEXT) selector for selectors containing text. Example: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_contains_selector.py

from seleniumbase import BaseCase

class ContainsSelectorTests(BaseCase):
    def test_contains_selector(self):
        self.open("https://xkcd.com/2207/")
        self.assert_element('div.box div:contains("Math Work")')
        self.click('a:contains("Next")')
        self.assert_element('div div:contains("Drone Fishing")')

More examples here: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_tinymce.py

from seleniumbase import BaseCase

class TinyMceTests(BaseCase):
    def test_tinymce(self):
        s…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by mdmintz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants