Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

verifyTrue (FALSE) causes AssertionError: null

View previous topic View next topic Go down

verifyTrue (FALSE) causes AssertionError: null

Post by stacaz on Thu Jun 24, 2010 2:37 am

I have the error: "java.lang.AssertionError: null" with the following code:


import java.util.Calendar;
import java.util.Properties;
import java.util.Vector;
import junit.framework.AssertionFailedError;
import java.lang.AssertionError;
import javax.mail.*;
import javax.mail.internet.*;
import com.thoughtworks.selenium.*;


try {
. . . previous code steps. . . .
verifyTrue(selenium.isTextPresent("some text is here");
. . . other code . . . .

} Catch SeleniumException e){
some code

} Catch AssertionFailedError e){
some code

} Catch Exception e){
some code

} Catch Error e){
some code
}


I have nailed the error down to the verifyTrue line.

I have also tried assertTrue(selenium.isTextPresent("some text here");, but it throws a "null" exception and stops the test run in the middle.

How do you verify if text is on a web page???

Thanks!

stacaz

Posts : 4
Join date : 2010-06-11

Back to top Go down

Re: verifyTrue (FALSE) causes AssertionError: null

Post by metman on Thu Jun 24, 2010 3:15 am

Well, that code shouldn't compile, given that you are missing a close paren. Otherwise, what is your actual search string? There could be something funky going on with the formatting there.

metman
Amateur
Amateur

Posts : 58
Join date : 2010-04-02

Back to top Go down

Re: verifyTrue (FALSE) causes AssertionError: null

Post by stacaz on Thu Jun 24, 2010 3:33 am

That's not all the code. What I am trying to figure out is why the catch is not trapping verifyTrue, and why an assertTrue does not work like I want either. I am new to Selenium and J-Unit, and very rusty on Java. There is much here than shown. And it all works fine, except for the 'verifyTrue' lines.

Here is it more accurately, showing the relevant sections:


import java.util.Calendar;
import java.util.Properties;
import java.util.Vector;
import junit.framework.AssertionFailedError;
import java.lang.AssertionError;
import javax.mail.*;
import javax.mail.internet.*;
import com.thoughtworks.selenium.*;

[prior code here]


try {
selenium.setTimeout("10000");
selenium.open(url);
assertEquals("Whatever text", selenium.getTitle()); //this works fine
selenium.click("SubmitBtn");
verifyTrue(selenium.isTextPresent("Whatever Text"); //causes the 'AssertionError: null' in failure trace.
assertTrue(selenium.isTextPresent("Also Whatever Text"); //error gets caught, but stops the whole test and output of the exception is "null".
}

catch (AssertionFailedError e) { some stuff here }
catch (AssertionError e) { some stuff here }
catch (Exception t) { some stuff here }
catch (Error e) { some stuff here }


[rest of code here]

stacaz

Posts : 4
Join date : 2010-06-11

Back to top Go down

Re: verifyTrue (FALSE) causes AssertionError: null

Post by stacaz on Thu Jun 24, 2010 3:36 am

Here is the actual verifyTrue line:

verifyTrue(selenium.isTextPresent("ERROR\r\nPlease enter your Cell Phone Number in the following format: ###-###-####\r\nIt should be ten digits long beginning with your area code."));

stacaz

Posts : 4
Join date : 2010-06-11

Back to top Go down

Re: verifyTrue (FALSE) causes AssertionError: null

Post by stacaz on Thu Jun 24, 2010 3:54 am

Ok, I simplified it down to this very short piece of code after removing everything else. Apparently you can't use \r and \n as new line and return. I have removed those.

So, I get no errors when "test text" is on the page, but I get the AssertionError: null in the trace log when "test text" is NOT on the page:

verifyTrue(selenium.isTextPresent("test text"));

Why am I getting this error?? How do I catch the error when that text does NOT appear on the web page without blowing up the test?

I still have those catch blocks per the above post. But apparently none of them are catching the error!

stacaz

Posts : 4
Join date : 2010-06-11

Back to top Go down

Re: verifyTrue (FALSE) causes AssertionError: null

Post by metman on Thu Jun 24, 2010 4:30 am

I'd suggest using assertTrue from jUnit rather than verifyTrue. That's what I use for these types of things, and it works fine for me. Also, if you read the JavaDocs, raw string is not the default interpretation for isTextPresent. Try prepending "exact:" to the beginning of your search string and see if that works any better. No guarantees, but that's what I'd try. Smile

metman
Amateur
Amateur

Posts : 58
Join date : 2010-04-02

Back to top Go down

Re: verifyTrue (FALSE) causes AssertionError: null

Post by Sponsored content Today at 1:05 pm


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum