Hi jWebUnit-Users,
 
I'm stuck with <button>-tags. They normally have their description in the body, 
and in my case they have neither attribute "id" nor "value".
So I tried with XPath. 
 
I used this little html-code:
 
<html>
<body>
 <h1>ButtonTest</h1><br>
 <form>
     <p>
        <textarea id="textfeld" cols="20" rows="4" name="textfeld"></textarea>
        <button type="button" id="Text1" value="Text2" name="Text1" 
onclick="this.form.textfeld.value='Text 1 und rückwärts seltsam geschrieben ich 
bin.'">Text1</button>
        <button type="button" id="Text2" value="Text2" name="Text2" 
onclick="this.form.textfeld.value='Ich bin Text 2 - ganz normal'">Text2</button>
     </p>
 </form>
 
</body>
</html>
 
so I could try using clickButton, clickButtonWithText and clickElementByXPath:
 
 public void testButtonWithXPath()
 {
  assertTextPresent("ButtonTest");
  assertElementPresentByXPath("//button[text()='Text1'");
  clickElementByXPath("//button[text()='Text1'");
  assertTextPresent("Text 1 und rückwärts seltsam geschrieben ich bin.");
  clickElementByXPath("//button[text()='Text2'");
  assertTextPresent("Ich bin Text 2 - ganz normal");
 }
 
 public void testButtonWithID()
 {
  assertTextPresent("ButtonTest");
  clickButton("Text1");
  assertTextInElement("textfeld", "Text 1 und rückwärts seltsam geschrieben ich 
bin.");
  clickButton("Text2");
  assertTextInElement("textfeld", "Ich bin Text 2 - ganz normal");
 }
 
 public void testButtonWithValue()
 {
  assertTextPresent("ButtonTest");
  clickButtonWithText("Text1");
  assertTextInElement("textfeld", "Text 1 und rückwärts seltsam geschrieben ich 
bin.");
  clickButtonWithText("Text2");
  assertTextInElement("textfeld", "Ich bin Text 2 - ganz normal");
 }
 
testButtonWithXPath() can not find the button. I don't know why. I checked it 
with the Firefox plugin "XPath Checker" which found it that way.
 
Anyway I wondered why there is no function to check the body of buttons? This 
would be valuable for jWebUnit-users, or did I miss some other simple way?
 
But with this demo I realized that neither assertTextPresent nor 
assertTextInElement or assertTextFieldEquals are able to get the text out of 
the textarea ...
How can I do this?

Thanx for any help in advance,
 
Dirk.
 
[->] Dirk Jerusalem
Quality Software Engineer & Service Engineer
Research & Development

[->] abaXX Technology AG
Forststr. 7 · 70174 Stuttgart · Germany
Phone: +49 1805 222-994
Fax: +49 1805 222-993
Mail: [EMAIL PROTECTED] <blocked::blocked::mailto:[EMAIL PROTECTED]> 
Surf~In: support.abaXX.de <blocked::blocked::http://support.abaxx.de/> 
Web: www.abaXX.de <blocked::blocked::http://www.abaxx.de/> 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
JWebUnit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to