my experience seems to be that in general I use xpath as a last resort to identifying elements. it's almost impossible to read (e.g. know by reading the code what element is being manipulated) and it tends to break the moment anyone re-designs any portion of the page that affects the 'path' to an object.
Far better to identify by ID or Name or some other characteristic that is unique to the element, or a container wrapped around the element. Secondly on pages with a lot of client side javascript, the page may require a little bit of time from when the browser says 'the page is done loading' (in other words, the last request of the webserver for page content has completed) and when all objects in the DOM have actually been created and are ready to be interacted with. In general that means you might need a small wait (see 'how to wait with water' <http://wiki.openqa.org/display/WTR/How+to+wait+with+Watir>) before you start trying to interact with the page. Generally if you can execute script steps manually a line at a time in IRB and they work, but they fail when the entire script is run 'at machine speed' then this kind of synchronization is the issue and you'll need to insert some small wait delays in front of elements that are being created/ rendered via client side scripting instead of existing in the HTML as downloaded from the website Lastly before writing automation code against any website you do not own, check the terms of service for the site to see how they feel about accessing the site with automation. Many sites prohibit it in their user agreement unless you get permission first (academic purposes or not) On Jun 5, 6:35 am, edipofederle <[email protected]> wrote: > Hello everyone, is my first contact with Watir and am really enjoying > it, but I have a problem to run the following test: > > https:/ /gist.github.com/1008964 > > is a simple test that logs into a gmail account and a text verefica > (Mail) via XPath, but the test fails and says that the element was not > found, read the documentation that the Waitresses 'wait' then load the > page that I create the element is there .. Can someone ajuar me with > this? > > Note: This is for an academic work and I chose it for Watir. -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected]
