Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
stacaz
Posts : 4
Join date : 2010-06-11

verifyTrue (FALSE) causes AssertionError: null Empty verifyTrue (FALSE) causes AssertionError: null

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!
avatar
metman
Amateur
Amateur
Posts : 58
Join date : 2010-04-02

verifyTrue (FALSE) causes AssertionError: null Empty Re: verifyTrue (FALSE) causes AssertionError: null

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.
avatar
stacaz
Posts : 4
Join date : 2010-06-11

verifyTrue (FALSE) causes AssertionError: null Empty Re: verifyTrue (FALSE) causes AssertionError: null

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]
avatar
stacaz
Posts : 4
Join date : 2010-06-11

verifyTrue (FALSE) causes AssertionError: null Empty Re: verifyTrue (FALSE) causes AssertionError: null

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."));
avatar
stacaz
Posts : 4
Join date : 2010-06-11

verifyTrue (FALSE) causes AssertionError: null Empty Re: verifyTrue (FALSE) causes AssertionError: null

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!
avatar
metman
Amateur
Amateur
Posts : 58
Join date : 2010-04-02

verifyTrue (FALSE) causes AssertionError: null Empty Re: verifyTrue (FALSE) causes AssertionError: null

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
Sponsored content

verifyTrue (FALSE) causes AssertionError: null Empty Re: verifyTrue (FALSE) causes AssertionError: null

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