Can I test a page structure to ensure the 'absence' of unwanted code?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Can I test a page structure to ensure the 'absence' of unwanted code?

GW-5
I can always use the DOM viewer to visually scan the structure of a web page, but I want to try and do that function as part of a test.

I'm trying to get my head around how I can work this - so any comments are appreciated. I'm not a developer - the way I use selenium is quite basic - as is my understanding of the scope of how I can use it.

I'm trying to find elements that [i]shouldnt [/i]be there, but I don't know how to do it, because I don't know what they'd be called - we're talking about a scenario where someone puts some extra code into the page that they shouldnt have.

I can check for the existence of elements on the page, and their 'ordering' using the verifyElementPresent command. I can do this by explicitly specifiying the path (i.e. by using the id of the elements rather than using the more general xPath).
so I could do a verifyElementPresent on

//html/body/div[@id="wrap"]/div[@id="contentwrap"]/div[@id="content"]/div[@id="sub-navwrap"]

and would know that this element exists beneath a specific structure.


The problem is, that this check wouldnt pick up an extra div that someone slotted in there, because presumably that div would be closed following any code thats been added. The path, therefore, would remain as it is stated above and no errors would be found.

Can anyone point me in the right direction?
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1871&messageID=5307#5307

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can I test a page structure to ensure the 'absence' of unwanted code?

Dan Fabulich
Lynn wrote:

> Can anyone point me in the right direction?

I believe the command you want there is "assertElementNotPresent" in the
HTML Selenese mode.  If you're running in one of the languages supported
by Selenium RC, you'll need to wrap up your call to "assertElementPresent"
in a try/catch block instead.

-Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can I test a page structure to ensure the 'absence' of unwanted code?

GW-5
In reply to this post by GW-5
> The problem is, that this check wouldnt pick up an extra div that someone slotted in there

Check the last-child.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1871&messageID=5350#5350

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can I test a page structure to ensure the

GW-5
In reply to this post by Dan Fabulich
um - I'm not sure how to use assertElementNotPresent without knowing what element I'm looking for. Thats my prob. I'm trying to flag up 'rogue' elements, but I only know what [i]should [/i]be on the page.

Can you elaborate for me with an example if I'm being dozy

thanks for your response.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1871&messageID=5361#5361

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can I test a page structure to ensure the 'absence' of unwanted code?

GW-5
In reply to this post by GW-5
> > The problem is, that this check wouldnt pick up an
> extra div that someone slotted in there
>
> Check the last-child.

Can you elaborate for me on this too by example? I don't understand what you're asking me to check. What I think you mean by the child, is in the example I'm giving, the final element in the path (in this case "sub-navwrap").

What I think youre saying to do is check for the nonexistance of //div[@id="content"]/<last-child>

but how do I check for this if I don't know what <last-child> is?


I guess what I'm trying to do is a

verifyElementNotPresent on

//div[@id="content"]/div[@id NOT EQUALS "sub-navwrap"]


thanks for your response.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1871&messageID=5362#5362

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Re: Can I test a page structure to ensure the 'absence' of unwanted code?

Alexandre Garel

Lynn a écrit :

>>> The problem is, that this check wouldnt pick up an
>>>      
>> extra div that someone slotted in there
>>
>> Check the last-child.
>>    
>
> Can you elaborate for me on this too by example? I don't understand what you're asking me to check. What I think you mean by the child, is in the example I'm giving, the final element in the path (in this case "sub-navwrap").
>
> What I think youre saying to do is check for the nonexistance of //div[@id="content"]/<last-child>
>
> but how do I check for this if I don't know what <last-child> is?
>  
I think he was talking about doing something like
verifyAttribute | xpath=//div[last()]@id |sub-navwrap
>
> I guess what I'm trying to do is a
>
> verifyElementNotPresent on
>
> //div[@id="content"]/div[@id NOT EQUALS "sub-navwrap"]
>
>  
I think your this may be correct too

Another way of doing it would have to have a user extension which just
evaluate the value of an XPath expression and compares it with a result like
assertXPath | count(//div) | 4
I think this may be a useful extension to selenium.
Hope it helps
Alex.




Ce message est protégé par les règles relatives au secret des correspondances. Il est donc établi à destination exclusive de son destinataire. Celui-ci peut donc contenir des informations confidentielles. La divulgation de ces informations est à ce titre rigoureusement interdite. Si vous avez reçu ce message par erreur, merci de le renvoyer à l'expéditeur dont l'adresse e-mail figure ci-dessus et de détruire le message ainsi que toute pièce jointe.

This message is protected by the secrecy of correspondence rules. Therefore, this message is intended solely for the attention of the addressee. This message may contain privileged or confidential information, as such the disclosure of these informations is strictly forbidden. If, by mistake, you have received this message, please return this message to the addressser whose e-mail address is written above and destroy this message and all files attached.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Re: Can I test a page structure to ensure the

GW-5
>
> Another way of doing it would have to have a user
> extension which just
> evaluate the value of an XPath expression and
> compares it with a result like
> assertXPath | count(//div) | 4
> I think this may be a useful extension to selenium.

See the following for how to write such an extension:
http://wiki.openqa.org/display/SEL/storeassertXpath
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1871&messageID=5375#5375

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can I test a page structure to ensure the

GW-5
In reply to this post by GW-5
I'd use x-path or DOM

dom=anElement.lastChild
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1871&messageID=5415#5415

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can I test a page structure to ensure the

GW-5
lastChild could also be whitespace text, though.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1871&messageID=5416#5416

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]