How to check non-existence of a button
Do you know how can I verify that a certain button does not exist on a page? What verification point should I use? Thanks.
Re: How to check non-existence of a button
I had to deal with the same situation. Here are the steps I followed (before learning to dynamically look for objects, which I am now using);
- Record you script where the button would exist on the screen under test.
- Add the button to your repository and add code to check for its existence in your script (Verification Point).
- Run the script against the screen where the button will exist and where it does not exist (to make sure that the routine works fine).
I used code similar to the following, to check that a specific button is not on my screen:
strBtnCaption = button_save().getProperty(".value").toString();
if (button_save().exists() && strBtnCaption.equalsIgnoreCase("Save Info"))
logTestResult("The 'Save Info' button exists.", false);
logTestResult("The 'Save Info' button was not found.", true);
RFT sometimes gets confused. If the button that I am looking for does not exist on my screen, it will try to find another button (and there is usually another one. That is the reason that I am extracting the text from the button before doing a check.