How to continue with script execution even if assert fails.

2,021 views
Skip to first unread message

santosh h s

unread,
Jul 21, 2011, 3:18:06 PM7/21/11
to seleniu...@googlegroups.com
How to continue with script execution even if assert fails.


--

/Santosh

dpak kumar

unread,
Jul 21, 2011, 3:22:05 PM7/21/11
to seleniu...@googlegroups.com
try verify commands

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

Luke Inman-Semerau

unread,
Jul 21, 2011, 3:22:23 PM7/21/11
to seleniu...@googlegroups.com
use verify instead (if you're talking about the individual test case)

would need to know what your test runner is in order to help you if you want the test case to fail and all subsequent tests to still run

On Thu, Jul 21, 2011 at 12:18 PM, santosh h s <santos...@gmail.com> wrote:
--

santosh h s

unread,
Jul 21, 2011, 3:31:14 PM7/21/11
to seleniu...@googlegroups.com
i tried verify commands but it was showing the error as command not available.
below is my assert command
assertTrue(selenium.isTextPresent("san"));
i modified the above command to verify as
verifyTrue(selenium.isTextPresent("san")); but this throws an error saying command is not available, let me know whether syntax is proper or not.
please provide sample Java syntax. 
--

/Santosh

santosh h s

unread,
Jul 21, 2011, 4:30:23 PM7/21/11
to seleniu...@googlegroups.com
any solutions for this please let me know proper syntax for verify statement
--

/Santosh

Moises Siles

unread,
Jul 21, 2011, 5:42:51 PM7/21/11
to seleniu...@googlegroups.com
take a look in the following thread


I think you can find your answer in that link, I had the same problem, now I'm catching all the fail asserts in my log file, and I can see the TC as failed in the Testrunner

Regards

santosh h s

unread,
Jul 22, 2011, 1:38:00 AM7/22/11
to seleniu...@googlegroups.com
let me know the syntax for verify statement in Selenium in for Java. code snippet will be useful

gulsha...@gmail.com

unread,
Jul 22, 2011, 1:22:07 AM7/22/11
to Selenium Users
I am facing no issues in verify and assert. Below is sample script as
example
package com.example.tests;

import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.regex.Pattern;

public class sample extends SeleneseTestCase {
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://
in.yahoo.com/");
selenium.start();
}

@Test
public void testSample() throws Exception {
selenium.open("/?p=us");
verifyTrue(selenium.isTextPresent("Yahoo! Firefox"));
assertTrue(selenium.isTextPresent("Yahoo! Firefox"));
}

@After
public void tearDown() throws Exception {
selenium.stop();
}
}


On Jul 22, 2:42 am, Moises Siles <moises.si...@gmail.com> wrote:
> take a look in the following thread
>
> http://groups.google.com/group/selenium-users/browse_thread/thread/18...
>
> I think you can find your answer in that link, I had the same problem, now
> I'm catching all the fail asserts in my log file, and I can see the TC as
> failed in the Testrunner
>
> Regards
>
> On Thu, Jul 21, 2011 at 2:30 PM, santosh h s <santosh.s...@gmail.com> wrote:
>
>
>
>
>
>
>
> > any solutions for this please let me know proper syntax for verify
> > statement
>
> > On Fri, Jul 22, 2011 at 1:01 AM, santosh h s <santosh.s...@gmail.com>wrote:
>
> >> i tried verify commands but it was showing the error as command not
> >> available.
> >> below is my assert command
> >> assertTrue(selenium.isTextPresent("san"));
> >> i modified the above command to verify as
> >> verifyTrue(selenium.isTextPresent("san")); but this throws an error saying
> >> command is not available, let me know whether syntax is proper or not.
> >> please provide sample Java syntax.
>
> >> On Fri, Jul 22, 2011 at 12:52 AM, Luke Inman-Semerau <
> >> luke.seme...@gmail.com> wrote:
>
> >>> use verify instead (if you're talking about the individual test case)
>
> >>> would need to know what your test runner is in order to help you if you
> >>> want the test case to fail and all subsequent tests to still run
>

Scott O

unread,
Jul 21, 2011, 5:56:54 PM7/21/11
to Selenium Users
I think to use verify you cannot simply replace the word assert with
the word verify in the C# code (or whatever language). I noticed that
when I replaced assertTextPresent with verifyTextPresent in the
Selenese and then re-exported to C#, the resulting code still had the
assertTrue command but it was wrapped in the "try" wording. Something
like this (it's not exact but you get the picture):

BEFORE
assertTrue(x)

AFTER
try {
assertTrue(x)
}

I think I know what you're trying to do, but based on what I've
mentioned above I wouldn't expect replacing assertTrue with verifyTrue
to work the way you're expecting. If you download the IDE and play
with the different types of assertions and exporting them to whatever
language you are using, you'll see what I mean. Hope this helps!

On Jul 21, 5:42 pm, Moises Siles <moises.si...@gmail.com> wrote:
> take a look in the following thread
>
> http://groups.google.com/group/selenium-users/browse_thread/thread/18...
>
> I think you can find your answer in that link, I had the same problem, now
> I'm catching all the fail asserts in my log file, and I can see the TC as
> failed in the Testrunner
>
> Regards
>
> On Thu, Jul 21, 2011 at 2:30 PM, santosh h s <santosh.s...@gmail.com> wrote:
>
>
>
>
>
>
>
> > any solutions for this please let me know proper syntax for verify
> > statement
>
> > On Fri, Jul 22, 2011 at 1:01 AM, santosh h s <santosh.s...@gmail.com>wrote:
>
> >> i tried verify commands but it was showing the error as command not
> >> available.
> >> below is my assert command
> >> assertTrue(selenium.isTextPresent("san"));
> >> i modified the above command to verify as
> >> verifyTrue(selenium.isTextPresent("san")); but this throws an error saying
> >> command is not available, let me know whether syntax is proper or not.
> >> please provide sample Java syntax.
>
> >> On Fri, Jul 22, 2011 at 12:52 AM, Luke Inman-Semerau <
> >> luke.seme...@gmail.com> wrote:
>
> >>> use verify instead (if you're talking about the individual test case)
>
> >>> would need to know what your test runner is in order to help you if you
> >>> want the test case to fail and all subsequent tests to still run
>

santosh h s

unread,
Jul 22, 2011, 1:17:53 PM7/22/11
to seleniu...@googlegroups.com
 if i use verify it throws an error can not find the symbol.but if i replace verify with assert everything works fine please refer my attached script and let me know what changes are required to make it work with verify statement also.
TestNGTest.java
Reply all
Reply to author
Forward
0 new messages