On Feb 22, 1:52 pm, Željko Filipin <
zeljko.fili...@gmail.com> wrote:
> On Wed, Feb 22, 2012 at 3:45 PM, Jamison Dance <
jerga...@gmail.com> wrote:
> > Is there any way to capture the current state of an element?
>
> Sure, try this:
>
> browser.element.html
>
> I think both watir and watir-webdriver gems support attribute_value, too:
>
>
http://rubydoc.info/gems/watir-webdriver/Watir/Element#attribute_valu...http://rubydoc.info/gems/watir/Watir/Element#attribute_value-instance...
The problem is, if there is javascript that is running 'onload' then
it's going to be a race between watir trying to examine the object,
and javascript that might be modifying it.
potentially to automate somethign like this, you might have to request
the HTML directly with something like HTTP-Party, parse it with
something like nokogiri, and pull out the stated attributes that would
be there as the page loads, and before any CSS rules or Javascript
have done their thing.
if you just want to observe and verify and not automate a test for
this, something like fiddler2 (if you are on windows) would let you
look at every raw file that went into composing the page, as they were
transferred from the server, so you could find the thing in the HTML
files, and compare the attributes there with what is seen in the dom
using developer tools. Developer tools can also show you things like
applied styles etc.
What is the purpose of a test like this? seems like a fair bit of
effort, and if the item is being altered on the fly, does the original
state really matter that much, or just that it ends up in the correct
state after all CSS rules and Javascript have done their thing?