Closed aarongarrett closed 8 years ago
Well, I just implemented the behavior myself, so I'm including that here in case others have the same question, and then I'll close the issue.
import org.robotframework.javalib.annotation.RobotKeyword;
import org.robotframework.javalib.annotation.RobotKeywords;
import org.robotframework.javalib.annotation.ArgumentNames;
import org.robotframework.swing.context.Context;
import org.netbeans.jemmy.operators.JRadioButtonMenuItemOperator;
import org.netbeans.jemmy.operators.ContainerOperator;
import javax.swing.JRadioButtonMenuItem;
public class MenuItemKeywords {
@RobotKeyword("Returns whether the given radio button menu item is selected.\n")
@ArgumentNames({"menuItemText"})
public boolean radioButtonMenuItemIsSelected(String menuItemText) {
ContainerOperator context = (ContainerOperator)Context.getContext();
JRadioButtonMenuItemOperator operator = new JRadioButtonMenuItemOperator(context, menuItemText);
JRadioButtonMenuItem item = (JRadioButtonMenuItem)operator.getSource();
return item.isSelected();
}
}
I don't see anywhere among the keywords a way to get the state of a JRadioButtonMenuItem. I tried
Radio Button Should Be Selected
andMenu Item Should Be Checked
, neither of which worked. Is there any way to determine the state of a radio button menu item? Or is there some other more common use case for doing the same thing I want to do (i.e., have mutually exclusive options in a menu)?