Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium - do WebElement objects store their data or retrieve it "live"?

If I instantiate a WebElement object, will getAttribute calls (and other calls that extract information about the element) successfully return the correct data even if that data changes after the object is created?

I had created an object map of sorts for a table of elements, and so I'm concerned that if I make alterations to any of the elements that are stored in this map, I'll need to re-set the objects in order to update the map with changes. It made me wonder how Selenium's WebElement works under the hood: do they read in all the attribute data and other information when they're created and spit that static data out thereafter, or do they simply contain references to the "real" UI element and retrieve the data dynamically every time?

like image 201
James Martineau Avatar asked Jun 25 '26 03:06

James Martineau


1 Answers

I believe that it reads the data when you trigger get Attribute.

Get the value of a the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded.

like image 155
Yogendra Singh Avatar answered Jun 27 '26 19:06

Yogendra Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!