Bill,
I am not an expert by any means but I suggest that you refine your tag search more. More specifically I am unsure that .value returns the inner html. I think I would approach your problem this way:
String htmlText = spec.find.html().getInnerHTML();
If (htmlText.matches(“.*Welcome to your account.*”) {
// Do something
} else {
// Do something else
}
Frankly watij is programmed agilely but is only partially intuitive. Its libraries have functionality similar to JavaScript… yet it requires java syntax(unless you are using ruby). It is a useful library but its documentation sucks. The authors will say this is by design since documentation goes out of date and it is better to have functions/methods that do what you think. I am sure you can see the problem with their logic. The bottom line is if your functionality is simple, this is a great tool for the novice. If your functionality is more complex it seems like you are going to have to use source code examination and trial and error as your guide.
One more note, in my experience with the library it is very sensitive to poorly structured html. For example, if you have an image tag “<img src=”img/somefile.jpg” >” which leaves off the closing slash “/” then wajit’s Tag object will not work past that point. While it is certainly simpler to create a strict parser it is not as generally useful on a fault tolerant language like html…
Best Regards,
Lance Jensen
Circuit Design Repair & Diagnostics (F.I.B. Edit)
Office Phone: (972)-995-8910 Cell: (214)-882-3888
Avoid the Top 5 FIB Edit Roadbumps
Priority Coordinators:
HPA: Chris Haga c-h...@ti.com
HVAL: Lisa Fritz l-fr...@ti.com
PWR: Naweed Anjum naw...@ti.com
WTBU: Kevin O'Halloran k-oha...@ti.com
ASP: Debra Guillemaud d-guil...@ti.com
From: wa...@googlegroups.com [mailto:wa...@googlegroups.com]
On Behalf Of Bill S.
Sent: Tuesday, September 04, 2012 10:07 PM
To: wa...@googlegroups.com
Subject: WebSpec: After navigating to a page, how to find whether text exists 'anywhere on the page'?
I'm trying to find the WebSpec equivalent of this from watir (ruby):
if browser.text.include? "Welcome to your account"
I see the ShouldHave methods for tags, but I don't want find the tag because if it shows anywhere on the page, it is fine. I've tried this:
spec.browser().find.html().shouldHave.value("Welcome to your account")
, but it isn't finding the text (even though I see it on the screen) and it throws an exception. What is the correct way to do this?
Thank you!
Bill
--
You received this message because you are subscribed to the Google Groups "watij" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/watij/-/hj8PwLwenbcJ.
To post to this group, send email to wa...@googlegroups.com.
To unsubscribe from this group, send email to watij+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/watij?hl=en.