Perhaps you will encounter the same problem, using the Selenium IDE to record a radio box or a multi-box, in the script, if you want to choose different cases, depending on the use case, select the various boxes or multi-box business process, how to maintain in the Webdriver code? Here are two simple ways to handle this:
Method One:
Webelement select = Dirver.findelement (By.xpath ("//selenium")); list<webelement> alloptions = select.findelements (by.tagname ("option")); for (Webelement option:alloptions) { System.out.println (String.Format ("Value is:%s", Option.getvalue ())); If (option.getvalue () = = "Guangzhou") { option.setselected ();} }
Method Two:
Select select = New Select (Driver.findelement (By.xpath ("//select")); Select.deselectall (); Select.selectbyvisibletext ("Guangzhou");
In the code, the first select element of the page is selected, all the radio boxes are deselected, and a single box with the text "Guangzhou" is selected.
Obviously, the second method runs more efficiently than the first because the first method also iterates through all the radio elements.
As an example of a single box, it can be used as a way to solve the problem of multi-marquee.