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

ContainsText(stringToValidate);

2 Answers 45 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
SD
Top achievements
Rank 1
SD asked on 08 Jul 2010, 06:14 AM
Hi there,

Is there an equivalent to ContainsText() in order to verify whether a button exists or not ? 
In the past I've been using an Xpath expression like //input[@value="Button caption name"]
and based on the return value which was true/false I could determine the existence of the button on the page. 

Ta, 
SD. 

2 Answers, 1 is accepted

Sort by
0
Missing User
answered on 12 Jul 2010, 03:50 PM
Hi SD,

I' not sure of a method that will return a boolean as you mentioned in the framework. Typically, when a page element is not found by a find method, null is returned by the method.

You can try using the Wait.ForExists() as in:

Find.ByExpression<HtmlButton>("Xpath=//input[@value=\"Button caption name\"]").Wait.ForExists();

Sincerely,
Nelson Sin
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
SD
Top achievements
Rank 1
answered on 14 Jul 2010, 06:48 AM
Ta for that...
For some reason it slips my mind find.xx returns NULL..;-)
If anyone interested that's an option for a test function that validates if a button exists on  a page...

public bool IsButtonExist(string buttonGUIName)
    {
        StringBuilder buffer = new StringBuilder();
        buffer.Append("//input[@value=\"")
              .Append(buttonGUIName)
              .Append("\"]");
 
        if (Manager.ActiveBrowser.Find.ByXPath(buffer.ToString()) == null)
        {
            return false;
        }
        else
            return true;
    }
Tags
General Discussions
Asked by
SD
Top achievements
Rank 1
Answers by
Missing User
SD
Top achievements
Rank 1
Share this question
or