Difference between getText () and getAttribute () in Selenium

** ・ getText ()… Get the text in the specified tag. ** ** If you want text surrounded by tags, click here.

** ・ getAttribute (String param)… Get the value of the attribute passed as an argument. ** ** If you want value, this is it.

<input id="sample" attr1="aaa" attr2="bbb" attr3="ccc">foo</input>

String test = driver.findElement(By.id("sample").getAttribute(attr1) // "aaa"
String test = driver.findElement(By.id("sample").getAttribute(attr2) // "bbb"
String test = driver.findElement(By.id("sample").getAttribute(attr3) // "ccc"
String test = driver.findElement(By.id("sample").getText // foo

Reference: http://stackoverflow.com/questions/32307702/difference-b-w-gettext-and-getattribute-in-selenium-webdriver

Recommended Posts

Difference between getText () and getAttribute () in Selenium
Difference between final and Immutable in Java
Difference between pop () and peek () in stack
Difference between "|| =" and "instance_variable_defined?" In Ruby memoization
Difference between EMPTY_ELEMENTDATA and DEFAULTCAPACITY_EMPTY_ELEMENTDATA in ArrayList
Difference between int and Integer in Java
Difference between vh and%
Difference between i ++ and ++ i
Difference between next () and nextLine () in Java Scanner
Difference between product and variant
Difference between redirect_to and render
[Java] Difference between == and equals
Difference between puts and print
Difference between redirect_to and render
About the difference between classes and instances in Ruby
Difference between new and create in Rais action controller
Difference between CUI and GUI
[Java] Difference between static final and final in member variables
Difference between variables and instance variables
Difference between mockito-core and mockito-all
Difference between class and instance
Difference between ArrayList and LinkedList
Difference between List and ArrayList
Difference between .bashrc and .bash_profile
Difference between StringBuilder and StringBuffer
Difference between render and redirect_to
Difference between render and redirect_to
About the difference between "(double quotation)" and "single quotation" in Ruby
Jersey --What is Difference Between bind and bindAsContract in HK2?
Difference between element 0, null and empty string (check in list)
Is short-circuit evaluation really fast? Difference between && and & in Java
[Ruby] Difference between get and post
Difference between instance method and class method
Difference between render method and redirect_to
Difference between interface and abstract class
Difference between == operator and equals method
[Java] Difference between Hashmap and HashTable
[Terminal] Difference between irb and pry
JavaServlet: Difference between executeQuery and executeUpdate
[Ruby] Difference between is_a? And instance_of?
Difference between == operator and eqals method
Rough difference between RSpec and minitest
Understand the difference between each_with_index and each.with_index
Difference between instance variable and class variable
[JAVA] Difference between abstract and interface
Difference between Thymeleaf @RestController and @Controller
Difference between Stream map and flatMap
Difference between primitive type and reference type
Difference between string.getByte () and Hex.decodeHex (string.toCharaArray ())
[Java] Difference between Closeable and AutoCloseable
[Java] Difference between StringBuffer and StringBuilder
[Java] Difference between length, length () and size ()
[rails] Difference between redirect_to and render
[Android] Difference between finish (); and return;
Difference between byCharWrapping and byWordWrapping of UI Label in Japanese display
Note: Difference between Ruby "p" and "puts"
Difference between Ruby instance variable and local variable
About the difference between irb and pry
Arrylist and linked list difference in java
Difference between addPanel and presentModally of FloatingPanel
[Ruby] Difference between print, puts and p