Search code examples
pythonseleniumexpected-condition

Selenium - Difference between text_to_be_present_in_element and text_to_be_present_in_element_value


Can you illustrate the difference between text_to_be_present_in_element and text_to_be_present_in_element_value with an example, preferably in python ?

The following link seems to explain how text_to_be_present_in_element works but it's still unclear to me.

http://www.seleniumframework.com/python-basic/waits-and-synchronization/


Solution

  • text_to_be_present_in_element is text value, to get the value with selenium element.text or Javascript element.textContent or element.innerTEXT

    <p>this is text</p>
    

    text_to_be_present_in_element_value is value attribute for element, to get the value with selenium element.get_attribute('value') and with JS element.getAttribute('value')

    <input type="text" value="text value">
    <input type="button" value="button text value">