This is a migrated thread and some comments may be shown as answers.

how to check for the element that is not exist

1 Answer 59 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Zin-Mar
Top achievements
Rank 1
Zin-Mar asked on 02 Dec 2010, 11:00 AM
Hi Telerik team,

i would like to create a test that depends on 'Remove_Official_Target' link button as shown in my attachment(capture commitment1) .
If that link button exists, i'll do a, else, i'll do b.
Currently, i used an if...else statement in my coded step to perform that but it gives me an null exception error when the "'Remove_Official_Target" link doesn't exists.

The code behind if _ else is below.

.

        [CodedStep(@"Click 'RemoveLink'")]
        public void CaptureCommitmentTest_CodedStep()
        {
             if (Pages.FactoryPlanningSystem_2.RemoveLink.IsVisible())
            {
                // Click 'RemoveLink'
                Pages.FactoryPlanningSystem_2.RemoveLink.Click(false);
  
// Wait for 'TextContent' 'Contains' 'Official Target UnSet' on 'ContentPlaceHolder1LblTargetNonOfficialMessageSpan'
                HtmlSpan ContentPlaceHolder1LblTargetNonOfficialMessageSpan = Pages.FactoryPlanningSystem_2.ContentPlaceHolder1LblTargetNonOfficialMessageSpan;
                ContentPlaceHolder1LblTargetNonOfficialMessageSpan.Wait.ForExists(5000);
                Wait.For<HtmlSpan>(c => c.AssertContent().TextContent(ArtOfTest.Common.StringCompareType.Contains, "Official Target UnSet"), ContentPlaceHolder1LblTargetNonOfficialMessageSpan, 10000);
            }
  
                       // Add your test methods here...
        }
}

I try to if (Pages.FactoryPlanningSystem_2.RemoveLink.IsVisible())  with if (Pages.FactoryPlanningSystem_2.RemoveLink != null) .
It gives the same error.

Any advice on this?

1 Answer, 1 is accepted

Sort by
0
Keaegan
Telerik team
answered on 07 Dec 2010, 01:13 AM

Hi Zin-Mar,

Did you get our reply to your support inquiry on this ticket? Please let us know if you are still having the same issues with this facet.

All the best,
Keaegan
the Telerik team

Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
Tags
General Discussions
Asked by
Zin-Mar
Top achievements
Rank 1
Answers by
Keaegan
Telerik team
Share this question
or