getText vs getAttribute code example

Example: What are the differences between getText vs getAttribute

differences between getText() vs getAttribute("attribute");
-> getText();
        -> returns the TEXT of the given web element.
        -> return type is STRING
        -> it does not accept any arguments.
        -> it will return the text that is in between the opening tag and
        the closing tag.
    EX: <a href="https://facebook.com"> FACEBOOK </a>
    -> What will getText() method return?
        - return -> FACEBOOK
    -> getAttribute("attribute");
        - It will return the value of given attribute
        - Return type is STRING
        - It accepts a String arg
    EX: <a href="https://facebook.com" class="om56"> FACEBOOK </a>
        -> webelement.getAttribute("href") --> https://facebook.com
        -> webelement.getAttribute("class") --> om56
.getCssValue("cssAttribute")
    -> This method will return the value of given CSS attribute: such as,
    font-size, font-style, color etc...

Tags:

Misc Example