How do I determine text visibility in multiple elements #1431
-
This element has more than one on the page, and I try using 'self.is_text_visible', which will only look for the first element: Does seleniumBase provide methods for that? I have two needs:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I pass But I still want to judge text visibility in multiple elements |
Beta Was this translation helpful? Give feedback.
-
Use the 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):
self.open("https://seleniumbase.io/tinymce/")
self.wait_for_element("div.mce-container-body")
self.click('span:contains("File")')
self.click('span:contains("New document")')
self.click('span:contains("Paragraph")')
self.click('span:contains("Heading 2")')
self.switch_to_frame("iframe")
self.add_text("#tinymce", "Automate anything with SeleniumBase!\n")
self.switch_to_default_content()
self.click("button i.mce-i-image")
self.type('input[aria-label="Width"].mce-textbox', "300")
image_url = "https://seleniumbase.io/img/sb_logo_10.png"
self.type("input.mce-textbox", image_url + "\n")
self.switch_to_frame("iframe")
self.click("h2")
self.switch_to_default_content()
self.post_message("Automate anything with SeleniumBase!")
self.click('span:contains("File")')
self.click('span:contains("Preview")')
self.switch_to_frame('iframe[sandbox="allow-scripts"]')
self.post_message("Learn SeleniumBase Today!") You can use it with methods such as: |
Beta Was this translation helpful? Give feedback.
-
Thank you I did it the following way:
|
Beta Was this translation helpful? Give feedback.
Use the
TAG:contains(TEXT)
selector for selectors containing text. Example: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_contains_selector.pyMore examples here: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_tinymce.py