1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Checking IDs with Selenium & Python

Discussão em 'Python' iniciado por Stack, Setembro 16, 2025.

  1. Stack

    Stack Membro Participativo

    I am running a selenium test with python. I am having a specific problem with the following bit of html code.

    <span class="cke_label" id="cke_8_label">Source</span>


    I have tried the following:

    self.assert_element_present_by_class('Source button', 'cke_8_label', 'cke_label')**


    here's the function:

    def assert_element_present_by_class(self, description, id, name):
    sel = self.selenium
    try:
    self.assert_(sel.is_element_present("//" + id + "[contains(@class,'" + name + "')]"))
    logging.info('PASS: "' + description + '" is present')
    except Exception:
    logging.exception('FAIL: "' + description + '" is not present')


    This gives me this error.......


    File "Template_Designer_P37.py", line 293, in assert_element_present_by_class self.assert_(sel.is_element_present("//" + id + "[contains(@class,'" + name + "')]")) File "C:\Python27\lib\unittest\case.py", line 420, in assertTrue raise self.failureException(msg) AssertionError: False is not true
    ​

    I have tried a couple of other methods, such as simply trying to assert that the id exists.

    My hunch is that the problem surrounds the 'id'.

    Any thoughts?

    Continue reading...

Compartilhe esta Página