I agree with you, but frame was intentionally designed that way and that's 
what frame is being used. Raising the defect and fixing is not in my hand 
according to this project. 

Actually I worked in WATIR for first five years in my company but that was 
watir-classic not selenium based watir. But after that my company was sold 
to other company and they are using selenium Java binding and I am working 
with selenium-Java binding now. The project which I am working now is IDIT, 
here If I don't find any id, I can raise the defect by asking to add the id 
to the field. But still I don't find any need to ask them to add id while I 
code because I can write the xpath or css which would not be brittle until 
and unless they have undergone some major change. I Love WATIR for only one 
reason, the reason is, the waiting timings WATIR is maintaining from local 
language binding not from the driver level.

On Thursday, December 14, 2017 at 11:27:26 PM UTC+5:30, Chuck van der 
Linden wrote:

>
> On Wednesday, December 13, 2017 at 10:23:58 AM UTC-8, 
> rajagopal...@gmail.com <javascript:> wrote:
>>
>> It's not possible to locate element without xpath in some places, xpath 
>> is pretty important and also unlike watir-classic, new WATIR which uses 
>> selenium-webdriver does the exceptional job with xpath. I have written an 
>> xpath when I code yesterday for an insurance company
>>
>> @b.element(xpath: 
>> ".//*[@id='ApprovalManagerSearch']/following-sibling::div[1]").iframe(id: 
>> 'SearchPanel').element(:id, "adviser1").click
>>
>> You see, you can't locate this element without using xpath and ofcourse 
>> watir provides functions to form this xpath, but that's for beginners, not 
>> for the one who learnt very well. 
>>
>>
> Interesting example.  Why won't the following work?
>
> #(replace <tag_type> with the method for the type of element you want to 
> click on, e.g. .span or .div, etc) 
> b.iframe(id: 'SearchPanel').<tag_type>(:id, "adviser1").click 
>
>
> If the site is coded to meet the HTML standard 
> <https://www.w3.org/TR/html51/dom.html#the-id-attribute> then ID values 
> are unique within what most of us call a 'page' (technically it's the 
> element's home subtree 
> <https://www.w3.org/TR/html51/infrastructure.html#home-subtree>)   So you 
> should be able to directly access the iframe by ID, instead of having to 
> worry about the outer container.  Of course iframes effectively have their 
> own unique home-subtree so you do of course have to specify the iframe, 
> then the thing you want that is inside a subframe  (Yes, I know YOU already 
> know about iframes. Consider that last sentence for the benefit of other 
> readers.)
>
> Now, if the site isn't coded with valid HTML and ID values are not unique, 
> then I can see the need for the outer container.    Although I would take 
> issue with the statement that XML is the *only* way to select that as CSS 
> selectors also allow you to select adjacent siblings, as does the 
> .following_siblings watir method.  So claiming xpath is the only way is a 
> falsehood.
>
> (ah, see I was somewhat ninja'd by Titus)
>
> Now if the site was created by developers who don't care if they code to 
> standards, then I would still argue that watir code such as that below is 
> easier to follow, and update when needed than a giant xpath selector 
> (making up the html tag types as I don't have actual html to reference)  
>
> @b.div(id: 'ApprovalManagerSearch')
>   .following_siblings[1]
>   .iframe(id: 'SearchPanel')
>   .span(:id, "adviser1").click
>
>
> If this is a site you are testing, and it does not conform to the HTML 
> specification, I would file bugs against those spec violations.  There 
> really is no excuse for any developer to be producing a site with invalid 
> HTML and counting on the relative *tolerance and forgiveness of the 
> browser* to deal with their shitty HTML.  If they can't make the ID's 
> unique then I'd lobby to remove them and include some custom attribute 
> (data-*something* most likely) so you can select the one you want without 
> having to rely on an index as in my experience that's the most likely thing 
> to be brittle and break when the design of the site is altered.  That would 
> perhaps return the sites code to compliance with the spec and also increase 
> the testability of the site. 
>
> If it's a 3rd party site you have no control over, and presuming you are 
> not violating any terms of service regarding accessing the site via the use 
> of robots or automation, then sadly you just have to cope with the garbage 
> being produced by their developers.  Although frankly in that case I'd be 
> asking about an API as that is generally a superior way to interact with a 
> 3rd party platform.  
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to